From 9d182b14479106c6e9274bf9dcb6cd8ed33fdb62 Mon Sep 17 00:00:00 2001 From: Imanol Date: Thu, 29 Aug 2019 11:20:00 +0100 Subject: [PATCH 1/4] OPENEUROPA-2111: Remove English translations. --- README.md | 12 +++++++++++- oe_multilingual.install | 1 - oe_multilingual.post_update.php | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index decde15..c745631 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The OpenEuropa Multilingual module offers default multilingual features for the - Enable all 24 official EU languages - Provide an optional language switcher block on the [OpenEuropa Theme][1] site header region - Make sure that the administrative interface is always set to English -- Allow English to be translated so that the default English copy may be fixed or improved, if necessary +- (TEMPORARILY REMOVED) Allow English to be translated so that the default English copy may be fixed or improved, if necessary. **Table of contents:** @@ -183,6 +183,16 @@ In order to install the OpenEuropa Multilingual demo module follow [the instruct ./vendor/bin/drush en oe_multilingual_demo -y ``` +## Known Issues + +##### Enabling English translations allows configuration changes to override locale translations + +Having English translations available had an unintended consequence: when making changes to translatable config entities, +if the strings of this config entities were also available on locale they would get saved as translations. The functionality +was removed on OPENEUROPA-2111 and a solution is currently being investigated on OPENEUROPA-2244 + + + ## Contributing Please read [the full documentation](https://github.com/openeuropa/openeuropa) for details on our code of conduct, and the process for submitting pull requests to us. diff --git a/oe_multilingual.install b/oe_multilingual.install index bc6af6a..86e3755 100644 --- a/oe_multilingual.install +++ b/oe_multilingual.install @@ -32,7 +32,6 @@ function oe_multilingual_install() { \Drupal::configFactory() ->getEditable('locale.settings') ->set('translation.import_enabled', FALSE) - ->set('translate_english', TRUE) ->save(); // Make sure that English language prefix is set to "en". diff --git a/oe_multilingual.post_update.php b/oe_multilingual.post_update.php index 4242993..6b26bd9 100644 --- a/oe_multilingual.post_update.php +++ b/oe_multilingual.post_update.php @@ -16,3 +16,15 @@ function oe_multilingual_post_update_00001_invalidate_containers_cache(): void { \Drupal::service('kernel')->invalidateContainer(); } + +/** + * Disable English translation. + * + * Disable English translations to prevent configuration changes to be + * stored as locale translations. + */ +function oe_multilingual_post_update_00002_disable_english_translation(): void { + $locale_configuration = \Drupal::configFactory()->getEditable('locale.settings'); + $locale_configuration->set('translate_english', FALSE); + $locale_configuration->save(); +} From 09a7a12d1a52ee6777419c433f73913a907830f2 Mon Sep 17 00:00:00 2001 From: Imanol Date: Thu, 29 Aug 2019 13:10:33 +0100 Subject: [PATCH 2/4] OPENEUROPA-2111: Improve Readme and remove update method. --- README.md | 9 +++------ oe_multilingual.post_update.php | 12 ------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c745631..ee8c2d8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ The OpenEuropa Multilingual module offers default multilingual features for the - Enable all 24 official EU languages - Provide an optional language switcher block on the [OpenEuropa Theme][1] site header region - Make sure that the administrative interface is always set to English -- (TEMPORARILY REMOVED) Allow English to be translated so that the default English copy may be fixed or improved, if necessary. **Table of contents:** @@ -185,12 +184,10 @@ In order to install the OpenEuropa Multilingual demo module follow [the instruct ## Known Issues -##### Enabling English translations allows configuration changes to override locale translations - -Having English translations available had an unintended consequence: when making changes to translatable config entities, -if the strings of this config entities were also available on locale they would get saved as translations. The functionality -was removed on OPENEUROPA-2111 and a solution is currently being investigated on OPENEUROPA-2244 +##### Enabling string English string translation +Enabling English string translation can have unintended consequences when making changes to translatable configuration entities. +If these strings are available in locale, the change would get saved as EN translations. ## Contributing diff --git a/oe_multilingual.post_update.php b/oe_multilingual.post_update.php index 6b26bd9..4242993 100644 --- a/oe_multilingual.post_update.php +++ b/oe_multilingual.post_update.php @@ -16,15 +16,3 @@ function oe_multilingual_post_update_00001_invalidate_containers_cache(): void { \Drupal::service('kernel')->invalidateContainer(); } - -/** - * Disable English translation. - * - * Disable English translations to prevent configuration changes to be - * stored as locale translations. - */ -function oe_multilingual_post_update_00002_disable_english_translation(): void { - $locale_configuration = \Drupal::configFactory()->getEditable('locale.settings'); - $locale_configuration->set('translate_english', FALSE); - $locale_configuration->save(); -} From 0587a0f2eebac3eefed1a4cbd0d11e2c5f350786 Mon Sep 17 00:00:00 2001 From: Imanol Date: Mon, 2 Sep 2019 13:23:59 +0100 Subject: [PATCH 3/4] OPENEUROPA-2111: Fix tests. --- composer.json | 3 ++- tests/Behat/InterfaceTranslationContext.php | 4 +++- tests/Kernel/InstallationTest.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9869f76..f23906f 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "openeuropa/drupal-core-require-dev": "^8.7", "openeuropa/task-runner": "~1.0@beta", "phpunit/phpunit": "~6.0", - "symfony/browser-kit": "~3.0 || ~4.0" + "symfony/browser-kit": "~3.0 || ~4.0", + "behat/mink-selenium2-driver": "1.4.x-dev as 1.3.x-dev" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", diff --git a/tests/Behat/InterfaceTranslationContext.php b/tests/Behat/InterfaceTranslationContext.php index dc27953..6d50e53 100644 --- a/tests/Behat/InterfaceTranslationContext.php +++ b/tests/Behat/InterfaceTranslationContext.php @@ -40,7 +40,9 @@ public function translateString(string $string, string $language, string $value) $source = $locale_storage->findString(['source' => $string]); if (!$source instanceof SourceString) { - throw new \Exception(sprintf('Missing string to translate: %s', $source)); + // We need to make sure the string is available to be translated. + $source = new SourceString(); + $source->setString($string)->setStorage($locale_storage)->save(); } // Backup existing translation. diff --git a/tests/Kernel/InstallationTest.php b/tests/Kernel/InstallationTest.php index a0006c6..98f525e 100644 --- a/tests/Kernel/InstallationTest.php +++ b/tests/Kernel/InstallationTest.php @@ -93,8 +93,8 @@ public function testInstallation(): void { // Ensure that remote translations downloading is disabled by default. $this->assertEquals(FALSE, $config->get('translation.import_enabled')); - // Ensure that the English language is translatable. - $this->assertEquals(TRUE, $config->get('translate_english')); + // Ensure that the English language is not translatable. + $this->assertEquals(FALSE, $config->get('translate_english')); $interface_settings = [ LanguageNegotiationAdmin::METHOD_ID => -20, From 95ae3883d822384d452cd40bc883dc664b48e7b5 Mon Sep 17 00:00:00 2001 From: upchuk Date: Tue, 3 Sep 2019 10:40:33 +0200 Subject: [PATCH 4/4] OPENEUROPA-2111: Using the locale storage to instantiate the string. --- tests/Behat/InterfaceTranslationContext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Behat/InterfaceTranslationContext.php b/tests/Behat/InterfaceTranslationContext.php index 6d50e53..279f124 100644 --- a/tests/Behat/InterfaceTranslationContext.php +++ b/tests/Behat/InterfaceTranslationContext.php @@ -41,8 +41,8 @@ public function translateString(string $string, string $language, string $value) $source = $locale_storage->findString(['source' => $string]); if (!$source instanceof SourceString) { // We need to make sure the string is available to be translated. - $source = new SourceString(); - $source->setString($string)->setStorage($locale_storage)->save(); + $source = $locale_storage->createString(); + $source->setString($string)->save(); } // Backup existing translation.