diff --git a/config_translation.admin.inc b/config_translation.admin.inc index bbac6b3..670ed93 100644 --- a/config_translation.admin.inc +++ b/config_translation.admin.inc @@ -182,10 +182,18 @@ function config_translation_item_translate_page($action, ConfigMapperInterface $ break; } + // Make sure we are in base config context. + // Example: visiting configuration page in other language. + config_context_enter('config.context.free'); + // Get base language configuration to display in the form before entering // into the language context for the form. This avoids repetitively going // in and out of the language context to get original values later. $base_config = $group->getConfigData(); + + // Leave base context to current context. + config_context_leave(); + config_translation_enter_context($language); return drupal_get_form('config_translation_form', $group, $language, $base_config); } diff --git a/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php b/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php index 1840763..68e3a7f 100644 --- a/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php +++ b/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php @@ -66,6 +66,8 @@ class ConfigTranslationUITest extends WebTestBase { function testSiteInformationTranslationUI() { $site_name = 'Site name for testing configuration translation'; $site_slogan = 'Site slogan for testing configuration translation'; + $fr_site_name = 'Nom du site pour tester la configuration traduction'; + $fr_site_slogan = 'Slogan du site pour tester la traduction de configuration'; $translation_base_url = 'admin/config/system/site-information/translate'; // Set site name and slogan for default language. @@ -86,8 +88,8 @@ class ConfigTranslationUITest extends WebTestBase { // Update site name and slogan for French. $edit = array( - '0[name]' => 'FR ' . $site_name, - '0[slogan]' => 'FR ' . $site_slogan, + '0[name]' => $fr_site_name, + '0[slogan]' => $fr_site_slogan, ); $this->drupalPost($translation_base_url . '/add/fr', $edit, t('Save translation')); $this->assertRaw(t('Updated French configuration translations successfully.')); @@ -99,13 +101,18 @@ class ConfigTranslationUITest extends WebTestBase { // Check translation saved proper. $this->drupalGet($translation_base_url . '/edit/fr'); - $this->assertFieldByName('0[name]', 'FR ' . $site_name); - $this->assertFieldByName('0[slogan]', 'FR ' . $site_slogan); + $this->assertFieldByName('0[name]', $fr_site_name); + $this->assertFieldByName('0[slogan]', $fr_site_slogan); // Check French translation of site name and slogan are in place. $this->drupalGet('fr'); - $this->assertRaw('FR ' . $site_name); - $this->assertRaw('FR ' . $site_slogan); + $this->assertRaw($fr_site_name); + $this->assertRaw($fr_site_slogan); + + // Visit French site to ensure base language string present as source. + $this->drupalGet('fr/' . $translation_base_url . '/edit/fr'); + $this->assertText($site_name); + $this->assertText($site_slogan); } /**