diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 5208d68..357aaf8 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -669,9 +669,8 @@ function locale_config_update_multiple(array $names, array $langcodes = array()) else { // Do not bother deleting language overrides which do not exist in the // first place. - $override = $language_manager->getLanguageConfigOverride($langcode, $name); - if (!$override->isNew()) { - $override->delete(); + if (!$language_manager->getLanguageConfigOverride($langcode, $name)->isNew()) { + $locale_config_manager->deleteTranslationData($name, $langcode); } } } diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index d66fc44..406e12c 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -169,6 +169,20 @@ public function saveTranslationData($name, $langcode, array $data) { } /** + * Deletes translated configuration data. + * + * @param string $name + * Configuration object name. + * @param string $langcode + * Language code. + */ + public function deleteTranslationData($name, $langcode) { + $this->isUpdating = TRUE; + $this->languageManager->getLanguageConfigOverride($langcode, $name)->delete(); + $this->isUpdating = FALSE; + } + + /** * Gets configuration names associated with components. * * @param array $components diff --git a/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php b/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php index 078d597..1afc0aa 100644 --- a/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php @@ -128,6 +128,9 @@ public function testDeleteTranslation() { $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); $this->deleteLanguageOverride($config_name, 'test', 'English test'); + // Instead of deleting the translation, we need to keep a translation with + // the source value and mark it as customized to prevent the deletion being + // reverted by importing community translations. $this->assertTranslation($config_name, 'English test'); } @@ -132,6 +132,17 @@ public function testDeleteTranslation() { } /** + * Tests deleting community translations of shipped configuration. + */ + public function testLocaleDeleteTranslation() { + $config_name = 'locale_test.translation'; + + $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); + $this->deleteLocaleTranslationData($config_name, 'test', 'English test'); + $this->assertNoTranslation($config_name, 'English test', FALSE); + } + + /** * Sets up a configuration string without a translation. * * The actual configuration is already available by installing locale_test