Problem/Motivation
Layout Builder does not support translated layout overrides currently. Any new sites installing Layout Builder will not be able to enable translation on Layout field through Content Translation.
But some sites that had both content translations and Layout Builder enabled before #3041659: Remove the layout tab from translations because Layout Builder does not support translations yet and had both translations and layout overrides on the same bundles maybe have Translations still enabled on the Layout field.
It could be not safe for them to just turn off translations because they may need the current values they have in the translated fields.
Proposed resolution
On Content Translation admin form add a warning to all Layout fields with a link to the handbook page https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder...
Only sites that were installed when Layout Builder was still beta will see this warning.
Remaining tasks
None
User interface changes
@see Proposed resolution
API changes
None
Data model changes
None
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#28 | 3043646-28.patch | 3.88 KB | tedbow |
#28 | interdiff-24-28.txt | 1.58 KB | tedbow |
#24 | 3043646-24.patch | 3.76 KB | tedbow |
#24 | interdiff-20-24.patch | 7.42 KB | tedbow |
#20 | Screen Shot 2019-03-28 at 10.21.39.png | 29.67 KB | lauriii |
Comments
Comment #2
xjmWe have a few options:
Comment #3
xjmI think this also applies to sites that might try turning this on in the future, since we're not disallowing it, only changing the default. I'd want those sites to see a warning that says "Enabling translation of this field won't do what you think it's going to."
Comment #4
tim.plunkettAre you saying we have to care about sites that *manually edit their config* to bypass the changes in our new patch?
Comment #5
effulgentsia CreditAttribution: effulgentsia at Acquia commentedFor entity types with no existing bundles using layout overrides, we're able to set it to untranslatable at the $field_storage level, which means it's not shown in the CT config form at all. No checkbox to enable, so no way to "try turning it on". Per #4, they'd have to do a config export, manually edit the YAML, then import those manual changes. I don't think we should cater to that.
But, for entity types with existing bundles using layout overrides, when layout overrides are added to a new bundle, we can only set that to untranslatable at the $field level, and therefore, that does show up in the CT config form as a checkbox that's unchecked but can be checked.
Comment #6
xjmRight, it's the second part of #5 I'm concerned about. Any site that has overrides is like a carrier of a disease for this problem, even if they don't use Content Translation already.
Comment #7
xjm@effulgentsia Maybe you could add STR to the IS showing the problem in that case? I think it's something like:
admin/config/regional/language
./admin/config/regional/content-language
.Comment #8
xjmI'm going from this in the CR:
Comment #9
xjmHere's another scenario I'm concerned about:
(Advance apologies to all the francophones for the typo in "ceci" in the screenshots.)
Should a message be put on this page? Status report message about this orphaned layout content? What?
Edit: This particular scenario affects only sites updating from (e.g.) 8.7.0-alpha1 to 8.7.0-beta1, so we'll want to differentiate between the two for the release note. I'll update the original issue accordingly.
Comment #10
xjm@tedbow clarified that the regression in #9 is specific to 8.7.x sites. I'll test from 8.6.x next.
Comment #11
bnjmnmAn issue similar to this is addressed in Paragraphs.
Fields of the type Paragraph are non-translatable, but are enabled by default in content translation, so they also need to inform the user that the field is not actually translatable.
A screenshot of the approach can be seen here #2760341: Let the user be aware that Paragraphs fields are not supported for translation
The "(* unsupported) Paragraphs fields do not support translation" message is always present at the top of the Content Translation form. The message is formatted as a warning unless a field of the type Paragraph is set as translatable, in which case it is formatted as an error.
Adding a message to the top of the Content Translation form + appending a warning to the field names seems like it would work here as well, and it would match a pattern that has likely been seen by many users already. I'd prefer if there was some kind of form validation involved so it wasn't even possible to enable translation for the field, but the fact that this validation wasn't implemented for Paragraphs suggests that there were implementation barriers or other good reasons for not including it.
Also note there has been interest in improving this experience in Paragraphs, but it has proven difficult to implement: #2787095: Improvements for translation settings
Comment #12
bnjmnmThis is an implementation of how it is approached in Paragraphs. The specifics of the solution for this haven't been fully hashed out yet, but this should be fairly easy to build from. Hopefully any additional changes just require changing the form_alter that is provided here.
Comment #13
tim.plunkettComment #14
xjmDiscussed with @dyannenova with @webchick. We've compromised on something like this:
(With the yellow triangle warning icon in place of [!].)
Comment #15
tedbow@xjm thanks for posting the image.
Here the 2 options neither is good. Neither is done but wanted to get feedback.
Render array fun
So putting actual html and not plaintext in with the label is very difficult because of what
_content_translation_preprocess_language_content_settings_table()
it move the different#
properties of the form around and puts #label in a #plain_text element and then within that section the $build there is nothing that actually gives us the machine of the field and the input is already rendered so we can't even find it from thatPlease observe
So we at least have to make a 1 line change to
_content_translation_preprocess_language_content_settings_table()
to set the field name to tell which element we need to alter.here is solution in that manner it is not finished but I would like feedback if this is the way we want to go.
The plain text option
We could just use hook_form_FORM_ID_alter to add a warning to the label but that gets set to #plain_text in
_content_translation_preprocess_language_content_settings_table()
so we can't have a link.Comment #16
tedbowHere is what I think is better option. Actually using the
#description
property of the checkbox but then changing_content_translation_preprocess_language_content_settings_table
to actually moving it which it should be doing anyways.I will also add another patch that simply sets
#description
and then moving it in_content_translation_preprocess_language_content_settings_table
could be a follow up.Basically I feel this last way is correct. But it looks bad because
_content_translation_preprocess_language_content_settings_table
does take into account that these form elements could have#description
Comment #17
tedbowHad to add a whole new library to get the css for this
interdiff is of 3043646-use_description-16.patch
Comment #18
tim.plunkettWeird space at the end of the A tag and you are missing a closing parentheses within the string
Otherwise, it looks like it's supposed to!
Comment #19
lauriiiMoved the icon a few pixels down to align with the text in Seven. I also converted the description class to use BEM and fixed #18.
Comment #20
lauriiiOops. I was in a bit hurry and accidentally forgot to update the value from Chrome debug tools to the patch.
Here's how this looks now:
Comment #21
webchickThat's more or less the spec that @DyanneNova came up with, so looks good.
Comment #24
tedbowOk chatted with @effulgentsia and @tim.plunkett.
We figure out a way to
Yay for small patches! thanks all!
Comment #25
tim.plunkettThis small addition to CT goes a long way!
While complex, this is a standard hook_theme_registry_alter implementation
Thanks everyone!
Comment #26
effulgentsia CreditAttribution: effulgentsia at Acquia commentedAll the PHP code, including the 1 line addition to content_translation, looks great to me.
Leaving the final review for a frontend framework manager.
Comment #27
lauriiiThis change looks great for me overall. This CSS is Seven specific. We should add a todo comment here to remember to move this to Seven as part of #3041053: Mark Layout Builder as a stable module.
Comment #28
tedbowFix #27 and fixed link to new online docs https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder...
Comment #29
tim.plunkett+1
Comment #30
tedbowComment #31
tedbowComment #33
larowlanComment #36
larowlanCommitted a83655a and pushed to 8.8.x. Thanks!
C/p as 7f5a4bc450 and pushed to 8.7.x
Comment #37
effulgentsia CreditAttribution: effulgentsia at Acquia commentedSo this doesn't just move it to after
content_translation_preprocess_language_content_settings_table()
, it moves it all the way to the end, including after theme preprocess functions. I think that's fine. I doubt there's any admin themes preprocessing this table in a way that would fail if the LB function comes after them. But, for anyone interested in there being an API for inserting things into desired positions of an array, there's #66183: Add helper methods to inject items into a particular position in associative arrays and possibly other similar issues.Comment #38
lauriiiComment #39
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThis patch was committed without a test. Which is fine, given the rush to get it in before beta. However, since it relies on the order in which preprocess functions run and internal details about another module's render array structure, and we may want to refactor it in 8.8.x to something more along the lines of #16, I think it could benefit from a test. Perhaps adding an extra assertion at the end of
MakeLayoutUntranslatableUpdatePathTestBase::testDisableTranslationOnLayouts()
for whether the warning appears on the form when we expect it to, and doesn't when we don't?