function LocaleConfigSubscriber::processTranslatableData

Same name in other branches
  1. 9 core/modules/locale/src/LocaleConfigSubscriber.php \Drupal\locale\LocaleConfigSubscriber::processTranslatableData()
  2. 8.9.x core/modules/locale/src/LocaleConfigSubscriber.php \Drupal\locale\LocaleConfigSubscriber::processTranslatableData()
  3. 11.x core/modules/locale/src/LocaleConfigSubscriber.php \Drupal\locale\LocaleConfigSubscriber::processTranslatableData()

Process the translatable data array with a given language.

Parameters

string $name: The configuration name.

array $config: The active configuration data or override data.

array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable: The translatable array structure. @see \Drupal\locale\LocaleConfigManager::getTranslatableData()

string $langcode: The language code to process the array with.

array $reference_config: (Optional) Reference configuration to check against if $config was an override. This allows us to update locale keys for data not in the override but still in the active configuration.

1 call to LocaleConfigSubscriber::processTranslatableData()
LocaleConfigSubscriber::updateLocaleStorage in core/modules/locale/src/LocaleConfigSubscriber.php
Update locale storage based on configuration translations.

File

core/modules/locale/src/LocaleConfigSubscriber.php, line 150

Class

LocaleConfigSubscriber
Updates strings translation when configuration translations change.

Namespace

Drupal\locale

Code

protected function processTranslatableData($name, array $config, array $translatable, $langcode, array $reference_config = []) {
    foreach ($translatable as $key => $item) {
        if (!isset($config[$key])) {
            if (isset($reference_config[$key])) {
                $this->resetExistingTranslations($name, $translatable[$key], $reference_config[$key], $langcode);
            }
            continue;
        }
        if (is_array($item)) {
            $reference_config_item = $reference_config[$key] ?? [];
            $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item);
        }
        else {
            $this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.