Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LocaleConfigSubscriber.php

function 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);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal