LocaleConfigManager
class LocaleConfigManager (View source)
Manages configuration supported in part by interface translation.
This manager is responsible to update configuration overrides and active translations when interface translation data changes. This allows Drupal to translate user roles, views, blocks, etc. after Drupal has been installed using the locale module's storage. When translations change in locale, LocaleConfigManager::updateConfigTranslations() is invoked to update the corresponding storage of the translation in the original config object or an override.
In turn when translated configuration or configuration language overrides are changed, it is the responsibility of LocaleConfigSubscriber to update locale storage.
By design locale module only deals with sources in English.
Properties
| protected StorageInterface | $configStorage | The storage instance for reading configuration data. |
|
| protected StringStorageInterface | $localeStorage | The string storage for reading and writing translations. |
|
| protected array | $translations | Array with preloaded string translations. |
|
| protected ConfigFactoryInterface | $configFactory | The configuration factory. |
|
| protected ConfigurableLanguageManagerInterface | $languageManager | The language manager. |
|
| protected TypedConfigManagerInterface | $typedConfigManager | The typed config manager. |
|
| protected bool | $isUpdatingFromLocale | Whether or not configuration translations are being updated from locale. |
|
| protected LocaleDefaultConfigStorage | $defaultConfigStorage | The locale default config storage instance. |
|
| protected ConfigManagerInterface | $configManager | The configuration manager. |
Methods
Creates a new typed configuration manager.
Gets array of translated strings for Locale translatable configuration.
Gets translatable configuration data for a typed configuration element.
Process the translatable data array with a given language.
Saves translated configuration override.
Saves translated configuration data.
Deletes translated configuration data.
Gets configuration names associated with components.
Gets configuration names associated with strings.
Deletes configuration for language.
Translates string using the localization system.
Reset static cache of configuration string translations.
Get the translation object for the given source/context and language.
Checks whether a language has configuration translation.
Returns the original language code for this shipped configuration.
Returns the current language code for this active configuration.
Whether the given configuration is supported for interface translation.
Indicates whether configuration translations are being updated from locale.
Updates all configuration translations for the names / languages provided.
Filters override data based on default translatable items.
Details
__construct(StorageInterface $config_storage, StringStorageInterface $locale_storage, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, ConfigurableLanguageManagerInterface $language_manager, LocaleDefaultConfigStorage $default_config_storage, ConfigManagerInterface $config_manager)
Creates a new typed configuration manager.
array
getTranslatableDefaultConfig(string $name)
Gets array of translated strings for Locale translatable configuration.
protected array|TranslatableMarkup
getTranslatableData(TypedDataInterface $element)
Gets translatable configuration data for a typed configuration element.
protected array
processTranslatableData(string $name, array $active, array $translatable, string $langcode)
Process the translatable data array with a given language.
If the given language is translatable, will return the translated copy which will only contain strings that had translations. If the given language is English and is not translatable, will return a simplified array of the English source strings only.
protected
saveTranslationOverride(string $name, string $langcode, array $data)
Saves translated configuration override.
protected
saveTranslationActive(string $name, array $data)
Saves translated configuration data.
protected
deleteTranslationOverride(string $name, string $langcode)
Deletes translated configuration data.
array
getComponentNames(array $components = [])
Gets configuration names associated with components.
array
getStringNames(array $lids)
Gets configuration names associated with strings.
deleteLanguageTranslations(string $langcode)
Deletes configuration for language.
string|false
translateString(string $name, string $langcode, string $source, string $context)
Translates string using the localization system.
So far we only know how to translate strings from English so the source string should be in English. Unlike regular t() translations, strings will be added to the source tables only if this is marked as default data.
$this
reset()
Reset static cache of configuration string translations.
TranslationString|false
getStringTranslation(string $name, string $langcode, string $source, string $context)
Get the translation object for the given source/context and language.
bool
hasTranslation(string $name, string $langcode)
Checks whether a language has configuration translation.
null|string
getDefaultConfigLangcode(string $name)
Returns the original language code for this shipped configuration.
null|string
getActiveConfigLangcode(string $name)
Returns the current language code for this active configuration.
bool
isSupported(string $name)
Whether the given configuration is supported for interface translation.
bool
isUpdatingTranslationsFromLocale()
Indicates whether configuration translations are being updated from locale.
int
updateConfigTranslations(array $names, array $langcodes = [])
Updates all configuration translations for the names / languages provided.
To be used when interface translation changes result in the need to update configuration translations to keep them in sync.
protected array
filterOverride(array $override_data, array $translatable)
Filters override data based on default translatable items.