protected function ConfigImportLocaleSubscriber::saveCustomizedTranslationNoOverwrite in Locale: Config import 8
Updates an interface translation if no previous translation is set.
Code is basically the same as LocaleConfigSubscriber::saveCustomizedTranslation, but with a more restrictive if-structure.
1 call to ConfigImportLocaleSubscriber::saveCustomizedTranslationNoOverwrite()
- ConfigImportLocaleSubscriber::saveCustomizedTranslation in src/
ConfigImportLocaleSubscriber.php - Saves a translation string and marks it as customized.
File
- src/
ConfigImportLocaleSubscriber.php, line 50
Class
- ConfigImportLocaleSubscriber
- This class extends the LocaleConfigSubscriber in Drupal\locale.
Namespace
Drupal\config_import_localeCode
protected function saveCustomizedTranslationNoOverwrite($name, $source, $context, $new_translation, $langcode) {
$locale_translation = $this->localeConfigManager
->getStringTranslation($name, $langcode, $source, $context);
if (!empty($locale_translation)) {
$existing_translation = $locale_translation
->getString();
if ($locale_translation
->isNew() && $source != $new_translation || !$locale_translation
->isNew() && empty($existing_translation) && $source != $new_translation) {
$locale_translation
->setString($new_translation)
->setCustomized(TRUE)
->save();
}
}
}