Native languanges aren't working

Created on 19 April 2023, over 1 year ago
Updated 21 April 2023, over 1 year ago

Problem/Motivation

On a site with language_hierarchy enabled, languages which are given a native name and an English translation always show English in the language switcher and the language overview reverts all names back to English on save.

Steps to reproduce

  1. Enable config overrides
  2. Add at least two languages
  3. Make one language a fallback of the other
  4. Give child language a native name and add a translation for the fallback language
  5. Add the language block to your site

Expected outcome:

  • Language switch link is displayed in his native language
  • Saving the overview form does not change/reset the previously set name

Actual result:

  • Language switch link is displayed in the fallback language
  • Saving the overview form reset the name to the fallback translation

Proposed resolution

  • When configuration translation is enabled, load native languages instead of using the languages from the form which are not in their original language
  • When checking overrides of language.entity.* for the same language, ignore any fallbacks because every language config entity has, per default, a name in its own language, even if core doesn't seem to report it.

See patch.

Remaining tasks

Test & review patch.

User interface changes

-

API changes

-

Data model changes

-

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇭Switzerland phma Basel, CH

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @phma
  • 🇬🇧United Kingdom james.williams

    Interesting! I can confirm I can make that bug show up on my client site, though the patch doesn't appear to actually fix it. Not sure why yet, but I'm also not sure special casing the language name is the right way to go. Why does it need special treatment in that way? Surely it's valid for the translation of a language name to use fallbacks, but to ensure it doesn't fallback when a name is available in the current / more specific language?

  • 🇨🇭Switzerland phma Basel, CH

    I checked my patch again in a clean Drupal 9.5.x installation with only langauge_herarchy 2.x-dev enabled and can confirm that the bug is both present and fixed by the patch I've provided.

    As why the special casing, I don't know. It has to do how Drupal deals with language configuration. If I remove it, language_hiearchy wrongly assumes there is no current translation and always uses the fallback instead of the default translation, which is wrong.

  • 🇨🇭Switzerland phma Basel, CH
Production build 0.71.5 2024