diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index 5d15dd5..26c90f6 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -387,11 +387,11 @@ public function getTypeLabel() { public function getLangcode() { $config_factory = $this->configFactory; $langcodes = array_map(function($name) use ($config_factory) { - // Default to English if no language code was provided in the file. - // Although it is a best practice to include a language code, if the - // developer did not think about a multilingual use-case, we fall back - // on assuming the file is English. - return $config_factory->get($name)->get('langcode') ?: 'en'; + // Default to site's default language if no language code was provided in + // the file. Although it is a best practice to include a language code, if + // the developer did not think about a multilingual use-case, we fall back + // on assuming the file is in site's default language. + return $config_factory->get($name)->get('langcode') ?: $this->languageManager->getDefaultLanguage()->getId(); }, $this->getConfigNames()); if (count(array_unique($langcodes)) > 1) { diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationNonEnglishSiteTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationNonEnglishSiteTest.php new file mode 100644 index 0000000..e676dcc --- /dev/null +++ b/core/modules/config_translation/src/Tests/ConfigTranslationNonEnglishSiteTest.php @@ -0,0 +1,53 @@ +drupalCreateUser(['administer content types', 'administer node fields', 'administer modules']); + $this->drupalLogin($account); + + // Set another language as default. Remove English. + ConfigurableLanguage::createFromLangcode('ro')->save(); + $this->config('system.site')->set('default_langcode', 'ro')->save(); + ConfigurableLanguage::load('en')->delete(); + + // Enable 'locale' and 'config_translation' modules. + $edit = [ + 'modules[Multilingual][config_translation][enable]' => 1, + 'modules[Multilingual][locale][enable]' => 1, + ]; + $this->drupalPostForm('admin/modules', $edit, t('Install')); + + $this->drupalGet('admin/structure/types/manage/article/fields'); + $this->assertText(t('Manage fields')); + } + +}