Problem/Motivation
As a followup from adding multilingual support:
#2414913: Support entity translation of paragraphs
The node form is now simultaneously editing multiple entities due to the composite relationship of the paragraphs.
The core translation handler displays "All languages" on the paragraph field, because it is on its own not translatable. While formally correct for the entity reference revision field, his is already confusing, since the target paragraph entities that represent paragraphs are inline editable can contain translatable fields.
Also "All languages" is somehow output recursively on the form items.

This behaviour seems to be wrong for all inline editing patterns and needs more analysis.
Proposed resolution
Fix the content translation handler or try to alter the (wrong) alterations. Add the #multilingual flag to the InlineParagraphs widget, which will remove the "all language" indicator in every scenario.
Remaining tasks
Check core to move to a solid API for modules to easily use the multilingual indication for even nested widgets e.g. Paragraphs or InlineEntiyForm.
User interface changes
API changes
# needs to be in submitted for this issue to work.
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | interdiff-2463575-46-50.txt | 1.21 KB | johnchque |
| #50 | wrong_all_languages-2463575-50.patch | 6.49 KB | johnchque |
| #46 | wrong_all_languages-2463575-46.patch | 6.47 KB | johnchque |
| #46 | interdiff-2463575-41-46.txt | 3.02 KB | johnchque |
| #46 | wrong_all_languages-2463575-46-test-only.patch | 3.3 KB | johnchque |
Comments
Comment #1
miro_dietikerNow the display is even worse. It shows
Text <span class="translation-entity-all-languages">(all languages)</span>(Yeah, the span tag is double encoded and clutters the UI.)
Promoting to major as it confuses users significantly.
Comment #2
sasanikolic commented#2532284: HTML is escaped in "all languages" in UI after SafeMarkup change should fix the double encoding of all languages.
Comment #3
sasanikolic commentedComment #4
tassilogroeper commentedI was discussing this issue with Berdir and plach. We came up with a quick fix, but we were not totally satisfied with the implementation.
So core does set the
#multilingualflag incore/modules/content_translation/content_translation.module:303in regard of the field definition - which is correct, assuming there are no nested or complex fields. But having widgets/modules like Paragraphs or InlineEntityForm being not translatable, but their nested forms - this will result in the misleading multilanguage indication on the children.There are two ways of implementing this:
1. wait for core issue #2575771: Do not overwrite #multilingual, if already set to be submitted and this patch will work, or
2. implement (and duplicate core code) the
core/modules/content_translation/content_translation.module:content_translation_form_alterand do the nested multilingual check in the paragraphs moduleComment #5
tassilogroeper commentedSo I was stepping through the code trying to implement a valid version of
core/modules/content_translation/content_translation.module:content_translation_form_alterforparagraphs.module, but failed to descent into the widgets fields by the core. This is then a core issue. I commented it in #2575771: Do not overwrite #multilingual, if already set.ATM removing the multilang indication is the only possible negotiation between core and nested field modules...
Comment #6
tassilogroeper commentedComment #7
gábor hojtsyComment #8
gábor hojtsyShould not add core tags, sorry :) Anyway, I wanted to add that this is a systemic question with field translation in general. It is always the case that a field may be a reference, and while the reference may not be translatable, the referred may be.
Comment #9
jeroen.b commentedComment #10
bojanz commentedI did the following workaround for IEF in #2494959: Add translation integration:
Comment #11
miro_dietiker@bojanz is this considered to be a workaround and there is a core issue we can refer to (such as core should recurse less)? or do we accept this as a "clean solution"? ;-)
Comment #12
bojanz commentedThis is a workaround. It will be simpler when #2575771: Do not overwrite #multilingual, if already set lands into core (cause we shoudl be able to just do $element['#multilingual'] = TRUE).
Comment #13
miro_dietikerBack to needs work, since #4 is not addressing the remaining items and we have a proposal how to complete implementation with a workaround.
Comment #14
luksakThe patch fixes the issue. Tests are missing and this needs to be tested with different field types in different configurations.
Comment #18
ytsurkI just tested the latest patch #14, and it removes unconditionally all (all languages) title postfixes,
even the one that actually are not translatable
Comment #19
berdirYes, see my comment that I just posted in #2731715: Hide shared fields when translating, related to that. We need to discuss this.
Comment #20
luksakNow the "all languages" is only being removed from the label if the field is translatable.
Comment #24
ytsurknow respects the untranslatable and nested fields/paragraphs. perfect, thx.
Comment #25
ytsurkhere's a patch passing the tests - hopefully ;)
Comment #26
luksakWhat do you mean by nested paragraphs? Didn't it work with my patch? I made two small improvements.
Comment #27
miro_dietikerLooks nice now, but we really need test coverage in a scenario where we have a translatable and an untranslatable field.
Comment #28
ytsurknested paragraphs are working with your patch Lukas.
Comment #29
johnchqueTests added. :)
Comment #33
berdirLooping over subform elements and then unconditionally accessing the field seems problematic?
Either loop over fields and check if the exist in the form or check if hasField($fieldname).
this hardcodes value.
what happens if you have an entity reference field, for example, that is/is not translatable?
Comment #34
johnchqueTrue, it didn't work with reference fields, also added tests for them. It even works with Nested paragraphs :D
Comment #38
berdirI don't like this syntax too much, static::class looks nicer to me (and works: https://3v4l.org/Uj6gJ ;) but that's minor.
I think "static::class . '::removeTranslatabilityCue'" would be even nicer, but apparently only works in PHP 7: https://3v4l.org/fW1st ?
Can we check if the element there actually has a title?
Wondering what will happen with form widget with multiple elements. Maybe instead of loop, we should look at the main property and try to use that?
Comment #39
berdirOne thing to check could be a date field, but I think those actually hide the title.
Maybe we could compare the titels and only update if they contain the title we want to replace it with or something?
Comment #40
miro_dietikerYeah, i guess we should check if #title is original #title + "(All languages)" and only then revert...
Something derived from addTranslatabilityClue():
Should be "Clue" not "Cue".
Comment #41
johnchqueTrue, there was some problems in the previous patch for some fields like image, link. Added tests for link field and changed the function to make it work. Also tested with double nesting works fine.
Comment #45
berdirAs Miro already said I think, some comments here to explain why we are doing it like this (widgets could have multiple elements with their own titles, so remove the suffix if it exists, do not recurse lower than this to avoid going into nested paragraphs or similar nested field types)
usually, a strpos() check is always done as a !== FALSE because it could also be 0, but since we don't expect that string to be at the first position, that seems OK here.
I think assertText() is enough, assertNoUniqueText() makes me think too much about what we are actually trying to do. Just making sure the text is there like that is enough.
Comment #46
johnchqueTrue, now should be fine. :)
Comment #50
johnchqueThis comment makes more sense.
Comment #51
berdirAgreed.
Comment #52
miro_dietikerHappy to commit this. Lots of peopl involved... :-) thx all!
And we're ready for a next RC. Party!