LocaleConfigSubscriber::resetExistingTranslations

protected LocaleConfigSubscriber::resetExistingTranslations($name, $translatable, $reference_config, $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.

Parameters

string $name: The configuration name.

array|\Drupal\Core\StringTranslation\TranslatableMarkup $translatable: Either a possibly nested array with TranslatableMarkup objects at the leaf items or a TranslatableMarkup object directly.

array|string $reference_config: Either a possibly nested array with strings at the leaf items or a string directly. Only those $translatable items that are also present in $reference_config will get translations reset.

string $langcode: The language code of the translation being processed.

File

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

Class

LocaleConfigSubscriber
Updates strings translation when configuration translations change.

Namespace

Drupal\locale

Code

protected function resetExistingTranslations($name, $translatable, $reference_config, $langcode) {
  if (is_array($translatable)) {
    foreach ($translatable as $key => $item) {
      if (isset($reference_config[$key])) {
        // Process further if the key still exists in the reference active
        // configuration and the default translation but not the current
        // configuration override.
        $this->resetExistingTranslations($name, $item, $reference_config[$key], $langcode);
      }
    }
  }
  elseif (!is_array($reference_config)) {
    $this->saveCustomizedTranslation($name, $translatable->getUntranslatedString(), $translatable->getOption('context'), $reference_config, $langcode);
  }
}
doc_Drupal
2016-10-29 09:23:58
Comments
Leave a Comment

Please login to continue.