Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294618

Language label logic when installing with language, adding and editing languages is confusing

$
0
0

Problem/Motivation

Creating languages right now is very inconsistent. I started looking into it because we have an issue in our install profile that the language was English and wouldn't update automatically when importing translations. What followed is a fun ride through language module and its history ;)

1. When installing Drupal in a specific language, the language label is created in English while everything else (as much as possible) is translated. This is related to #2031197: Language configuration entities should be created in English at all times, but that is a very old issue and we do *not* create them with langcode en anymore, the argument there is also wrong about selecting from an english list, see 2.. What we should do at that point is create the entity with the localized language label, which we do have access to.

2. When then adding a second language, the language label list is being translated to the current language, so I see e.g. "Französisch" there.

3. When then adding that language, it is again created with the english label and the config entity has the langcode of my current language (de in my case). At that point, I would expect that it is created as "Französisch" since langcode is de. It could also be in french, if the langcode would be french. Optimaly, we'd also already create a french translation after importing the french translations.

4. When I now edit that language and save it, whether or not I change the label, the langcode is changed to fr. That's because of some strange/old code in \Drupal\language\Form\LanguageFormBase that defines a hidden langcode property, which then accidently overwrites the langcode when it is actually supposed to be a hidden property for the ID. This predates the rename of the langcode property to id on the language config entity. There is also no reason to have that in the first place, this is an entity form and we have the entity object already available.

Proposed resolution

1. Create the language entity in the installer with the localized language code.
3. Create additional languages with the translated label into the correct language (==langcode property). Look into creating a translation. Maybe that could be a follow-up because it is likely more complicated.
4. Remove the langcode property for existing language entities to avoid accidently overriding that.

Remaining tasks

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 294618

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>