When you try to edit a translation which language is different than you have in your user account "Administration pages language" setting, you are redirected to the editing page in that language.

For example, if I try to edit a spanish translation and I have setted english in my user account, I'm redirected to the english edition page.

Steps to reproduce:

  1. Go to: /user/YOUR_USER/edit
  2. Set a value in 'Administration pages language' different to: '- No preference -'
  3. Try to edit a translation of any content, menu, taxonomy...
  4. Note the link points to the language setted in your user preferences.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

facine created an issue. See original summary.

Gábor Hojtsy’s picture

Did you encounter this with core only? I don't believe there is any language based redirects in core to begin with.

facine’s picture

Gábor Hojtsy’s picture

Title: Multilingual site and user "Administration pages language" setting » Administration pages language setting affects edit links to content translations

All right, so you are not redirected (note the URLs before clicking on them), but you get different URLs generated.

Gábor Hojtsy’s picture

Issue summary: View changes
krlucas’s picture

This seems to affect users who have access to edit entities. Users who can only translate can still access the translation links output on the entity translations overview page.

By design, it appears, ContentTranslationManageAccessCheck blocks editors access to the entity.$entity_type_id.content_translation_edit route:

 // Editors have no access to the translation operations, as entity
 // access already grants them an equal or greater access level.
 $templates = ['update' => 'edit-form', 'delete' => 'delete-form'];
 if ($entity->access($operation) && $entity_type->hasLinkTemplate($templates[$operation])) {
   return AccessResult::forbidden()->cachePerPermissions();
 }

And the overview controller always provides editors with links to the entity edit page:

  if ($update_access->isAllowed() && $entity_type->hasLinkTemplate('edit-form')) {
    $links['edit']['url'] = $entity->urlInfo('edit-form');
    $links['edit']['language'] = $language;
  }
  elseif (!$is_original && $translation_access->isAllowed()) {
    $links['edit']['url'] = $edit_url;
  }

But the entity.$entity_type_id.edit_form route always loads the translation of the currently negotiated language.

Allowing editors to edit translations in the admin interface language of their choice seems like a pretty big use case. When we build multi-lingual sites for clients the person creating nodes and adding translations frequently is just copying pasting and is not actually a speaker of the languages of the content they are entering.

Leksat’s picture

Title: Administration pages language setting affects edit links to content translations » Administration pages language setting makes it impossible to edit content translations for some roles

Would it make sense to add the translation language as an additional parameter to the entity edit route? Just like in D7 entity_translation we can edit a German translation within the English interface at /en/node/1/edit/de.

Also, if we decide to make it, I would not change the language in the URL. I mean that it would be nice that translation links at the /en/node/1/translations page lead to /en/node/1/edit/en and /en/node/1/edit/de, so no language interface switching happens.

If we implement the above, both "Account administration pages" language detection method and "Administration pages language" setting are useless and can be removed.

krlucas’s picture

+1 for #7 to add (back) a language suffix to the entity edit route and restore the D7 admin interface negotiation pattern. Seems like the simplest fix.

Leksat’s picture

Assigned: Unassigned » Leksat

Working on a patch.

Leksat’s picture

Assigned: Leksat » Unassigned
Status: Active » Needs review
FileSize
3.35 KB

Here is a patch.

1. It clones entity edit form route, adding the language parameter
2. It uses hook_entity_prepare_form() to set the entity translation (fetching language from the current route match)

I'd love to hear if there are better ways to implement this.

Leksat’s picture

From my #7:

If we implement the above, both "Account administration pages" language detection method and "Administration pages language" setting are useless and can be removed.

Actually there are many ways to get to an admin page in a non preferred language. So the mentioned features are still useful.

Leksat’s picture

Updated links on the entity overview page. Test fails are expected.

The only issue I see for now, tabs are gone on the edit form.

Status: Needs review » Needs work

The last submitted patch, 12: 2677778-12.patch, failed testing.

Leksat’s picture

Status: Needs work » Needs review
FileSize
4.66 KB
5.81 KB

Changed the whole thing a bit. Here is what the patch does:
- adds optional content_translation_language parameter to the edit route
- uses hook_entity_prepare_form() to set a desired entity translation on the form
- uses hook_entity_operation_alter() to add translation language to the edit link

Status: Needs review » Needs work

The last submitted patch, 14: 2677778-14.patch, failed testing.

Leksat’s picture

Status: Needs work » Needs review
FileSize
5.97 KB
1.32 KB

Fixed URL in test.

Leksat’s picture

Green light!

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Gábor Hojtsy’s picture

Leksat’s picture

Status: Needs review » Postponed
FileSize
275.72 KB

After some usage of #16 on a dev project, we found several issues with the patch. (I can provide some feedback if anyone is interested)

Now I think that we need to fix #2189267: When content language detection is different from interface language detection, the detected language is not applied to the rendered content first and then try to solve the issue with the language detection configuration.
Here is a screenshot of the configuration that should solve the issue:

@Gábor Hojtsy, thanks for mentioning that issue!

Gábor Hojtsy’s picture

Leksat’s picture