LocaleConfigSubscriber
class LocaleConfigSubscriber implements EventSubscriberInterface (View source)
Updates strings translation when configuration translations change.
This reacts to the updates of translated active configuration and configuration language overrides. When those updates involve configuration which was available as default configuration, we need to feed back changes to any item which was originally part of that configuration to the interface translation storage. Those updated translations are saved as customized, so further community translation updates will not undo user changes.
This subscriber does not respond to deleting active configuration or deleting configuration translations. The locale storage is additive and we cannot be sure that only a given configuration translation used a source string. So we should not remove the translations from locale storage in these cases. The configuration or override would itself be deleted either way.
By design locale module only deals with sources in English.
Properties
| protected ConfigFactoryInterface | $configFactory | The configuration factory. |
|
| protected LocaleConfigManager | $localeConfigManager | The typed configuration manager. |
|
| protected LanguageManagerInterface | $languageManager | The language manager. |
Methods
Constructs a LocaleConfigSubscriber.
{@inheritdoc}
Updates the locale strings when a translated active configuration is saved.
Updates the locale strings when a configuration override is saved/deleted.
Update locale storage based on configuration translations.
Process the translatable data array with a given language.
Reset existing locale translations to their source values.
Saves a translation string and marks it as customized.
Details
__construct(ConfigFactoryInterface $config_factory, LocaleConfigManager $locale_config_manager)
Constructs a LocaleConfigSubscriber.
static
getSubscribedEvents()
{@inheritdoc}
onConfigSave(ConfigCrudEvent $event)
Updates the locale strings when a translated active configuration is saved.
onOverrideChange(LanguageConfigOverrideCrudEvent $event)
Updates the locale strings when a configuration override is saved/deleted.
updateLocaleStorage(StorableConfigBase $config, string $langcode, array $reference_config = [])
Update locale storage based on configuration translations.
protected
processTranslatableData(string $name, array $config, array $translatable, string $langcode, array $reference_config = [])
Process the translatable data array with a given language.
protected
resetExistingTranslations(string $name, array|TranslatableMarkup $translatable, array|string $reference_config, string $langcode)
Reset existing locale translations to their source values.
Goes through $translatable to reset any existing translations to the source string, so prior translations would not reappear in the configuration.
protected
saveCustomizedTranslation(string $name, string $source, string $context, string $new_translation, string $langcode)
Saves a translation string and marks it as customized.