diff --git a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php new file mode 100644 index 0000000000000000000000000000000000000000..5061be2cdec15ed96d7da9aae3a547ac2b1efed2 --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php @@ -0,0 +1,65 @@ +entityManager->getStorageController($entity_type)) { + // Enter the override-free context, so we can ensure no overrides are + // applied. + config_context_enter('config.context.free'); + $entity = $storage->load($value); + // Leave the override-free context. + config_context_leave(); + return $entity; + } + } + + /** + * {@inheritdoc} + */ + public function applies($definition, $name, Route $route) { + if (parent::applies($definition, $name, $route)) { + // As we only want to override EntityConverter for ConfigEntities, find + // out whether the current entity is a ConfigEntity. + $entity_type = substr($definition['type'], strlen('entity:')); + $info = $this->entityManager->getDefinition($entity_type); + if (is_subclass_of($info['class'], '\Drupal\Core\Config\Entity\ConfigEntityInterface')) { + // path_is_admin() needs the path without the leading slash. + $path = ltrim($route->getPath(), '/'); + return path_is_admin($path); + } + } + return FALSE; + } + +} diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php index 752f911a2c42ca22780be4be1640ea1813fc1689..72998261ea0416101166ae322557fe22d9e430be 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -43,7 +43,7 @@ public function setUp() { function testConfigTranslation() { // Add custom language. $langcode = 'xx'; - $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form')); + $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms')); $this->drupalLogin($admin_user); $name = $this->randomName(16); $edit = array( @@ -164,6 +164,10 @@ function testConfigTranslation() { // upcasting will already work. $this->drupalGet($langcode . '/contact/feedback'); $this->assertText($category_label); + + // Check if the UI does not show the translated String. + $this->drupalGet('admin/structure/contact/manage/feedback'); + $this->assertFieldById('edit-label', 'Website feedback', 'Translation is not loaded for Edit Form.'); } } diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml index 776cb3bb5014cae9b83ba50e657ace8823feec1f..f8319893dc859834d8579bee26e872d6eb723157 100644 --- a/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -4,6 +4,11 @@ services: tags: - { name: event_subscriber } arguments: ['@language_manager', '@config.context'] + paramconverter.configentity_admin: + class: Drupal\locale\ParamConverter\LocaleAdminPathConfigEntityConverter + tags: + - { name: paramconverter, priority: 5 } + arguments: ['@entity.manager'] locale.config.typed: class: Drupal\locale\LocaleConfigManager arguments: ['@config.storage', '@config.storage.schema', '@config.storage.installer', '@locale.storage']