- Issue created by @司南
- Merge request !54Fix missing text format when rendering in translation languages. → (Open) created by 司南
- First commit to issue fork.
When message template is translated in another language, for example zh-hans,
render the message in that language will missing the format setting in the text field of the message template.
1. Create a message template config entity, set the text format to use a non-default format.
2. Translate the template to another language, for example: zh-hans.
3. Create a message of the template.
4. Render the message in zh-hans language.
5. We will see the message is rendered in zh-hans language, but not the format set in the message template.
This is because the \Drupal\language\Config\LanguageConfigOverride
object
only contain the language overrided properties values, doesn't contain the non-translatable properties values.
We need to merge to the original config values manually, there is a contrib module
translated_config →
focus on this task, but the code is very simple, we don't need to make dependency on it.
$config_translation_override = $language_manager->getLanguageConfigOverride($langcode, 'message.template.' . $this->id());
$config_translation = array_replace_recursive($this->toArray(), $config_translation_override->get());
$translated_text = $config_translation['text'];
none.
none.
none.
none.
Active
1.0
Code