Updated: Comment 0

Problem/Motivation

When you translate config entities appearing in the route slug they have the wrong language (default aka. en), so they aren't translated.

Proposed resolution

The problem is that the routing system comes before the current language context is resetted, chaning the priority a bit fixes that.
So first the locale config subscriber steps in and resets the current language once the request is available, then the routing system executes its logic and loads the config entity.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
950 bytes

This fixes the problem described in config_translation.

Gábor Hojtsy’s picture

Title: Config entities get the wrong language context » Config entities upcast from the request always get default language context
Issue tags: +sprint, +language-config
FileSize
1.66 KB

Here is an untested test only. :D

tstoeckler’s picture

  1. +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
    @@ -144,6 +144,31 @@ function testConfigTranslation() {
    +    // Enable the contact module.
    +    $this->drupalPostForm('admin/modules', array('modules[Core][contact][enable]' => "1"), t('Save configuration'));
    +    $this->resetAll();
    

    Can't we simply make contact.module a requirement of the test?

  2. +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
    @@ -144,6 +144,31 @@ function testConfigTranslation() {
    +    // translation. This test ensures the entity loaded from the request
    +    // upcasting will already work.
    

    I think "work" is not very precise. I would suggest "the entity loaded from the request upcasting has active locale overrides."

  3. +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
    @@ -144,6 +144,31 @@ function testConfigTranslation() {
    +    $this->assertTest($categry_label);
    

    Typo

Marking needs work for 3. at least.

webflo’s picture

Just put both patches together. Looks good. Fixed two issues in the test from comment 3.

+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php
@@ -144,6 +144,31 @@ function testConfigTranslation() {
+    $this->drupalGet($langcode . '/contact/feedback');
+    $this->assertTest($categry_label);

This page callbacks needs the permission "access site-wide contact form".

Typo in $categry_label

webflo’s picture

Gábor Hojtsy’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community
Issue tags: +blocker

Looks good to me. Let's get this in! Marking blocker for #1952394: Add configuration translation user interface module in core since this fails the perfect tests there :) The fails appeared now because contact was just recently converted to the routing system and upcast in the routing vs. the old menu hook based method.

tstoeckler’s picture

Priority: Major » Normal
Issue tags: -blocker

Looks good, thanks. The bot can prove me wrong, if it wants, but for humans this is RTBC.

tstoeckler’s picture

Priority: Normal » Major
Issue tags: +blocker

x-post.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Gábor Hojtsy’s picture

Issue tags: -sprint

Woot, yay!

Automatically closed -- issue fixed for 2 weeks with no activity.