Loading core/modules/locale/src/LocaleConfigManager.php +6 −4 Original line number Diff line number Diff line Loading @@ -597,7 +597,7 @@ public function updateConfigTranslations(array $names, array $langcodes = []) { $this->deleteTranslationOverride($name, $langcode); $count++; } elseif (!empty($data)) { elseif (!empty($data) && $override->get() !== $data) { // Update translation data in configuration override. $this->saveTranslationOverride($name, $langcode, $data); $count++; Loading @@ -607,12 +607,14 @@ public function updateConfigTranslations(array $names, array $langcodes = []) { // If the language code is the active storage language, we should // update. If it is English, we should only update if English is also // translatable. $active = NestedArray::mergeDeepArray([$active, $processed], TRUE); $this->saveTranslationActive($name, $active); $data = NestedArray::mergeDeepArray([$active, $processed], TRUE); if ($data !== $active) { $this->saveTranslationActive($name, $data); $count++; } } } } return $count; } Loading core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,22 @@ public function testLocaleDeleteActiveTranslation(): void { $this->assertEquals('Hungarian test', $this->configFactory->getEditable($config_name)->get('test')); } /** * Tests that unchanged active translations are not re-saved. */ public function testUnchangedActiveTranslationNotResaved(): void { $config_name = 'locale_test.translation'; // After setUp(), the Hungarian active translation already exists. Calling // updateConfigTranslations() again without changes should not re-save it. $this->localeConfigManager->reset(); $count = $this->localeConfigManager->updateConfigTranslations([$config_name], ['hu']); $this->assertSame(0, $count, 'Unchanged active config translation should not be re-saved.'); // Verify the active config is still intact. $this->assertActiveConfig($config_name, 'test', 'Hungarian test', 'hu'); } /** * Tests that adding English creates a translation override. */ Loading core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +19 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,25 @@ public function testLocaleDeleteTranslation(): void { $this->assertNoTranslation($config_name, 'de'); } /** * Tests that unchanged translations are not re-saved. * * Verifies that updateConfigTranslations() skips saving config overrides * when the computed translation data is identical to the existing override. */ public function testUnchangedTranslationNotResaved(): void { $config_name = 'locale_test.translation'; // After setUp(), the German override already exists. Calling // updateConfigTranslations() again without changes should not re-save it. $this->localeConfigManager->reset(); $count = $this->localeConfigManager->updateConfigTranslations([$config_name], ['de']); $this->assertSame(0, $count, 'Unchanged config translation should not be re-saved.'); // Verify the override is still intact. $this->assertConfigOverride($config_name, 'test', 'German test', 'de'); } /** * Sets up a configuration string without a translation. * Loading Loading
core/modules/locale/src/LocaleConfigManager.php +6 −4 Original line number Diff line number Diff line Loading @@ -597,7 +597,7 @@ public function updateConfigTranslations(array $names, array $langcodes = []) { $this->deleteTranslationOverride($name, $langcode); $count++; } elseif (!empty($data)) { elseif (!empty($data) && $override->get() !== $data) { // Update translation data in configuration override. $this->saveTranslationOverride($name, $langcode, $data); $count++; Loading @@ -607,12 +607,14 @@ public function updateConfigTranslations(array $names, array $langcodes = []) { // If the language code is the active storage language, we should // update. If it is English, we should only update if English is also // translatable. $active = NestedArray::mergeDeepArray([$active, $processed], TRUE); $this->saveTranslationActive($name, $active); $data = NestedArray::mergeDeepArray([$active, $processed], TRUE); if ($data !== $active) { $this->saveTranslationActive($name, $data); $count++; } } } } return $count; } Loading
core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberForeignTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,22 @@ public function testLocaleDeleteActiveTranslation(): void { $this->assertEquals('Hungarian test', $this->configFactory->getEditable($config_name)->get('test')); } /** * Tests that unchanged active translations are not re-saved. */ public function testUnchangedActiveTranslationNotResaved(): void { $config_name = 'locale_test.translation'; // After setUp(), the Hungarian active translation already exists. Calling // updateConfigTranslations() again without changes should not re-save it. $this->localeConfigManager->reset(); $count = $this->localeConfigManager->updateConfigTranslations([$config_name], ['hu']); $this->assertSame(0, $count, 'Unchanged active config translation should not be re-saved.'); // Verify the active config is still intact. $this->assertActiveConfig($config_name, 'test', 'Hungarian test', 'hu'); } /** * Tests that adding English creates a translation override. */ Loading
core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +19 −0 Original line number Diff line number Diff line Loading @@ -200,6 +200,25 @@ public function testLocaleDeleteTranslation(): void { $this->assertNoTranslation($config_name, 'de'); } /** * Tests that unchanged translations are not re-saved. * * Verifies that updateConfigTranslations() skips saving config overrides * when the computed translation data is identical to the existing override. */ public function testUnchangedTranslationNotResaved(): void { $config_name = 'locale_test.translation'; // After setUp(), the German override already exists. Calling // updateConfigTranslations() again without changes should not re-save it. $this->localeConfigManager->reset(); $count = $this->localeConfigManager->updateConfigTranslations([$config_name], ['de']); $this->assertSame(0, $count, 'Unchanged config translation should not be re-saved.'); // Verify the override is still intact. $this->assertConfigOverride($config_name, 'test', 'German test', 'de'); } /** * Sets up a configuration string without a translation. * Loading