diff --git a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathEntityConverter.php b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathEntityConverter.php new file mode 100644 index 0000000..3b55645 --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathEntityConverter.php @@ -0,0 +1,54 @@ +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} + * + * This converter applies only if the path is an admin path. + */ + public function applies($definition, $name, Route $route) { + if (parent::applies($definition, $name, $route)) { + // 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 752f911..7299826 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 f632704..71d6c3c 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.entity_admin: + class: Drupal\locale\ParamConverter\LocaleAdminPathEntityConverter + 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']