Problem/Motivation
UI Patterns is currently building a symmetric translation system for content storage only: #3548884: [trans] Make SourceValueItem field type translatable with synchronized and asynchron translations where:
- translations are flat list of translatable sources with their tree node IDs
- we rebuild the translated tree by overriding tree nodes values with translated values
On Display Builder side, we will leverage this feature and we need to do the same for our config entities: Page Layout, Views & Entity View Display.
Proposed resolution
- Make
sourceproperty translatable - Add a way of retrieving all nodes with translatable source plugins
- In
ConfigTranslationAddFormandConfigTranslationEditForm, expose those translatable source with the UI Patterns Form Builder (the final goal is to translate from Display Builder UI, but this will be a post-beta 1 target) - Make it store a flat list of nodes and build the full translated field when retrieving the value
Issue fork display_builder-3555110
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pdureau commentedWork has started
Comment #4
pdureau commentedThis is a beta2 target, there was some hope of doing in for beta1, but we need to follow the flow of #3548884: [trans] Make SourceValueItem field type translatable with synchronized and asynchron translations so let's take some more time and target beta2 as initially planned.
Comment #5
pdureau commentedComment #7
lauriiiWhat are you planning to use for determining which props should be translated? Asking because it might be good for us to coordinate on this so that we could provide a good experience for people who are using both Canvas and Display Builder.
Comment #8
pdureau commentedHi Laurii,
Our logic (which is not really the current MR, we didn't push yet the current work which is very promising) is not based in props, it is based on our data source plugin type:
I believe it would be a mistake to think about "translatable props":
What do you think about that?
Comment #9
lauriiiI'm trying to understand how are you determining what becomes available for translators in In
ConfigTranslationAddFormandConfigTranslationEditForm. Are you for example going to allow translating all data usingTextfieldWidgetor is there a selection that happens at a certain point by someone to determine what gets translated? Or are you making everything available for translation and letting the translator decide which data should be translated?Comment #10
pdureau commentedInstead of a
ComponentTreelike Canvas, we have aSourceTree, we nest data sources and each source plugin has its own config schema. So, by nesting the source plugins, we have a big config schema tree and we can extract the translatable strings.This abstraction is the core of our architecture since the start of UI Patterns 2 development in June 2023 .
Such selection is not necessary.
Comment #11
christian.wiedemann commentedComment #12
pdureau commentedComment #13
pdureau commentedSince beta2, we have a fake, temporary, implementation of
ContentEntityInterface, so ofTranslatableInterface, inDrupal\display_builder\Entity\ContentEntityBaseWe are still hesitating:
\Drupal\Core\Entity\ContentEntityBaseas a base class and adapt the custom logic inInstanceandInstanceStorageonly ?Anyway, even if we are focusing on tarnslatabilitty of the "providers" (integration with Drupal API) for now, the addition of this intreface may interest you.
Comment #14
pdureau commentedMoved to beta4 because we will merge #3549266: Move DisplayBuildableInterface to a new plugin type first.
Comment #15
pdureau commented#3549266: Move DisplayBuildableInterface to a new plugin type has been merged!
Comment #16
pdureau commentedInstance entities are now using
\Drupal\Core\Entity\ContentEntityBaseand are currently adopting the Field API to store the data (see #3562989: Implements RevisionLogInterface for Instance entity).Once done, we will be able to easily use the work from UI Patterns (#3548884: [trans] Make SourceValueItem field type translatable with synchronized and asynchron translations).
Comment #17
pdureau commentedComment #18
pdureau commentedComment #23
pdureau commentedI will resquash and do a review.
However, the priority is the UI Patterns ticket for now: #3548884: [trans] Make SourceValueItem field type translatable with synchronized and asynchron translations
Comment #26
pdureau commentedSquashed, rebased & linted.
We are back to 3555110-symmetric-config-translation-cw and this MR: https://git.drupalcode.org/project/display_builder/-/merge_requests/273
383 additional PHP LOC (tests excluded), that's lean for such a valuable feature 👍
My understanding:
Instance entity
A new method:
InstanceInterface::ensureCurrentTranslation(): InstanceInterface, called from 2 places only:InstanceTranslationSubscriberlisteningKernelEvents::REQUEST.ProfileViewBuilderAs said in a note, I am surprised such mechanism is needed, i was expecting the Entity API to do all the work.
Buildable plugins
A new method:
DisplayBuildableInterface::isTranslationSynchronized(): boolFor
EntityViewOverride: a very simple implementation, because we use the same field type in Instance entity and in overrides.For
EntityView,PageLayoutandViewDisplay, the logic is more complex and implemented in the newConfigBuildablePluginBase. This is where most of the logic happen and will be the main part of the review.Island plugins
A new "Language" col in the logs panel
Do we also display the current language in the Controls panel?
Comment #27
pdureau commented(removing
third_party_settingsin all examples for clarity)Page Layout
1. Just translating without messing with the sources tree
Test:
/test-translationspage with:Results:
It may be an issue not related to the current work, which may need its dedicated ticket, so let's try again with
/user/*page condition instead of/test-translation.Results:
Technical analysis
Just a guess, but the error may come from us not following config translations expectations with the addition of a translations property which is too specific and (obviously) not present in the original language:
I guess we don't need to mess with the default config translation storage: just a skeleton tree with only the translated values. So:
Then, Drupal Core APIs can do the merge deep they usually do at config load to get the full translated display. The
ConfigBuildablePluginBaseis translating between the UI Patterns source field storage and the "normal" config translation storage, in both direction.Is it possible ? Will it simplify our logic ?
2. Moving stuff around in the translated language
Later
3. Changing a non translatable value from original language
Later
Entity View, Entity View Overrides, View Display
Later.
Comment #28
pdureau commented