Problem/Motivation
On a site with multiple languages, using English as the default, when changing the order of the languages and moving English below another non-default language, this order causes language fallbacks to prioritize order over default status. E.g. English and Chinese Simplified translation exist, when trying to access a non-existent translation via URL prefix, the Chinese Simplified translation is shown instead of the English original source.
Steps to reproduce
- Enable Content Translation and Language
- Go to/admin/config/regional/language
- Add Languages: Chinese, Simplified, Chinese, Traditional, Spanish
- Reorder Languages to be alphabetical (Chinese systems first, English, Spanish)
- Set English as Default
- Go to /admin/config/regional/language/detection
- Customize Content language detection to differ from Interface
- Enable URL
- Configure URL
- Add “en” path prefix for English
- Go to /admin/structure/taxonomy
- Edit Tags vocab and Enable translation
- Under Tags, add a couple terms
- Translate one term in Chinese, Simplified and change name to differ from source
- Go to Tags vocab listing, edit the prefix in the URL from “en” to “es”
Result:
The taxonomy term that has Chinese translation shows the name value from that translation.
Expectation:
I would’ve expected it to use the default language, English. But I assume it’s taking the first value in the existing translations list and displaying it instead? Is this how it’s supposed to work, or does anyone know of a core issue about it?
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3315245
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
brittany.huntzberryAdding a note, when reordering the Languages so that English is the first one in the list, then the issue is resolved. I'm thinking this is due to getTranslationFromContext, looking for fallbacks and selecting the first valid translation in the list instead of default language.
You can also reproduce the issue with translations on content types like Article, Basic page.
Comment #3
tom verhaeghe commentedI have encountered this issue myself as well. The default language should be checked first as opposed to the first valid translation the system finds.
Comment #4
tom verhaeghe commentedComment #5
tom verhaeghe commentedComment #19
tom verhaeghe commentedI'm so sorry for the mess, it seems like there is a delay of 2 days between creating a merge request and the MR to appear in this overview. I didn't know, since this is my first go with gitlab merge requests. I made the mistake of creating multiple merge requests and that caused several jobs to run. Eitherway, the last build is the one that should be looked at, and quite a lot of tests fail. I'm unsure if my approach is the good one and i will check this.
Comment #20
dieterholvoet commentedUsing the MR from this issue, we're getting a bunch of warnings like this:
I'll push a fix to the MR.