/** * Deletes translation data from locale module. * * This will invoke LocaleConfigSubscriber through the event dispatcher. To * make sure the configuration was persisted correctly, the configuration * value is checked. Because LocaleConfigSubscriber temporarily disables the * override state of the configuration factory we check that the correct value * is restored afterwards. * * @param string $config_name * The configuration name. * @param string $key * The configuration key. * @param string $source_value * The source configuration value to verify the correct value is returned * from the configuration factory after the deletion. * @param string $langcode * The language code. */ protected function deleteLocaleTranslationData($config_name, $key, $source_value, $langcode) { $this->localeConfigManager->getStringTranslation($config_name, $langcode, $source_value, '')->delete(); $this->localeConfigManager->reset(); $this->localeConfigManager->updateConfigTranslations(array($config_name), array($langcode)); $this->configFactory->reset($config_name); $this->assertNoConfigOverride($config_name, $key, $source_value, $langcode); }
/** * Saves a translation string and marks it as customized. * * @param string $name * The configuration name. * @param string $source * The source string value. * @param string $context * The source string context. * @param string $translation * The translation string. * @param string $langcode * The language code of the translation. */ protected function saveCustomizedTranslation($name, $source, $context, $translation, $langcode) { $locale_translation = $this->localeConfigManager->getStringTranslation($name, $langcode, $source, $context); if (!empty($locale_translation)) { // Save this translation as custom if it was a new translation and not the // same as the source. (The interface prefills translation values with the // source). Or if there was an existing translation and the user changed // it (even if it was changed back to the original value). Otherwise the // translation file would be overwritten with the locale copy again later. if ($locale_translation->isNew() && $source != $translation || !$locale_translation->isNew() && $translation != $locale_translation->getString()) { $locale_translation->setString($translation)->setCustomized(TRUE)->save(); } } }