diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 98ab72b..36829d2 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -8,6 +8,7 @@ namespace Drupal\config_translation\Controller; use Drupal\config_translation\ConfigMapperManagerInterface; +use Drupal\config_translation\ConfigNamesMapper; use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Language\Language; @@ -132,7 +133,31 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl if (count($languages) == 1) { drupal_set_message($this->t('In order to translate configuration, the website must have at least two languages.', array(':url' => $this->url('entity.configurable_language.collection'))), 'warning'); } - $original_langcode = $mapper->getLangcode(); + + try { + $original_langcode = $mapper->getLangcode(); + } + catch (\RuntimeException $exception) { + $message = ''; + if ($mapper instanceof ConfigNamesMapper) { + $items = []; + foreach ($mapper->getconfigNames() as $config_name) { + $langcode = $mapper->getLangcodeFromConfig($config_name); + $items[] = $config_name .': ' . $this->languageManager->getLanguage($langcode)->getName(); + } + $message = [ + 'message' => ['#markup' => t('Configuration objects have different language codes:')], + 'items' => [ + '#theme' => 'item_list', + '#items' => $items, + ] + ]; + } + $page['message'] = $message; + return $page; + } + + if (!isset($languages[$original_langcode])) { // If the language is not configured on the site, create a dummy language // object for this listing only to ensure the user gets useful info. diff --git a/core/modules/node/src/Tests/NodeTypeTranslationTest.php b/core/modules/node/src/Tests/NodeTypeTranslationTest.php index a473233..627dffd 100644 --- a/core/modules/node/src/Tests/NodeTypeTranslationTest.php +++ b/core/modules/node/src/Tests/NodeTypeTranslationTest.php @@ -165,6 +165,7 @@ public function testNodeTypeTitleLabelTranslation() { $this->assertResponse(200); $this->drupalGet("es/admin/structure/types/manage/$type/fields/node.$type.field_email/translate"); $this->assertResponse(200); + $this->assertText("Configuration objects have different language codes"); } }