saveCustomizedTranslation example

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

  /** * 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. * * @param string $name * The configuration name. * @param array|\Drupal\Core\StringTranslation\TranslatableMarkup $translatable * Either a possibly nested array with TranslatableMarkup objects at the * leaf items or a TranslatableMarkup object directly. * @param 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. * @param string $langcode * The language code of the translation being processed. */
Home | Imprint | This part of the site doesn't use cookies.