- π§πͺBelgium weseze
2 remarks on this approach:
Templates that are stored in the library should have the language from the host entity from which they were cloned.
With the changes you are proposing this could differ. Assume you are editing a page in a certain language (Chinese), while keeping the admin interface in another language (English). The current language would be English, but the template you are storing in the library should remain in the Chinese language, because it was cloned from a Chinese language page.Templates cloned into a page from the library should take on the language of the entity on which they are cloned.
This is basically the same as the above, but in reverse.
It also applies when you are simply translating your website and using templates created in another language.I suggest passing the host entity to the clone functions and getting the language from there.
But I don't see anyway of doing that with the current code as it does not contain the host entity anywhere... - π§πͺBelgium Thomas Cys
Thomas Cys β made their first commit to this issueβs fork.
- Open on Drupal.org βCore: 10.1.4 + Environment: PHP 8.1 & MySQL 8last update
about 1 year ago Waiting for branch to pass - last update
about 1 year ago 2 fail - π§πͺBelgium kriboogh
"But I don't see anyway of doing that with the current code as it does not contain the host entity anywhere..."
I was looking at the code for this a bit. From the submitForm methods you could pass the section_storage context 'entity' which is assigned to $layout_entity (this is the node being edited) and pass that to the deepClone methods. There you can then use the $layout_entity->getLanguage()->getId() to set the langcode.
Also then set the langcode on the section being create or updated before the $section->save in the submitForm code after the cloning has been done.
$section->set('langcode', $layout_entity->language()->getId());I will try to cook up some patch.