Skip to content

Draft: Use QLocale in LanguageListModel instead of storing QString

Joshua Goins requested to merge work/redstrate/remove-manual-locale-strings into master

The Problem

A common language string might be "fr_FR.UTF-8". However, Plasma might complain that it's an unsupported language. When doing available language checks we only store the language code, e.g. "fr". Previously we did stuff like knocking off the UTF-8 at the end, but this was only sometimes and even then that's not the full spec. Also, we didn't remove the territory code - so it would think French is unsupported, despite "fr" being an available language for Plasma. Clearly, French does exist (at least to my knowledge)...

I was curious why this didn't affect American English users, until I was tipped off that en_US (yes! with the territory!) is put inside of the available language list, since it's the source language. So technically, it looks like this code is broken for everything except Americans...

The Solution

Fortunately for us, Qt already knows how to parse locale strings - so why not just store these as their QLocale counterparts instead? We're already using QLocale to get the native language names, so it makes sense to use them for everything.

I don't have any specific BUG codes yet. Also WIP, as some things are broken as noted in my own comments. This is a relatively harmless change though, I think.

@arrowdodger

Merge request reports