mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Improve automated language handling
This mimics the code added in commit cf990b0f39
("preferences: choose language
code with one '-'") and adds some debugging for the mobile case - some people
are being presented with Subsurface-mobile in Korean for some reason.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c7a929a8a8
commit
8f50c9c1b3
1 changed files with 10 additions and 6 deletions
|
@ -466,18 +466,22 @@ void initUiLanguage()
|
|||
auto it = std::find_if(languages.begin(), languages.end(), [](const QString &s)
|
||||
{ return s.count('-') == 1; });
|
||||
uiLang = it == languages.end() ? languages[0] : *it;
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
qDebug() << "uiLanguages was" << languages << ", picked" << uiLang;
|
||||
#endif
|
||||
|
||||
// there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info
|
||||
if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) {
|
||||
QLocale loc2(loc.bcp47Name());
|
||||
loc = loc2;
|
||||
QStringList languages = loc2.uiLanguages();
|
||||
if (languages[0].contains('-'))
|
||||
uiLang = languages[0];
|
||||
else if (languages.count() > 1 && languages[1].contains('-'))
|
||||
uiLang = languages[1];
|
||||
else if (languages.count() > 2 && languages[2].contains('-'))
|
||||
uiLang = languages[2];
|
||||
|
||||
it = std::find_if(languages.begin(), languages.end(), [](const QString &s)
|
||||
{ return s.contains('-'); });
|
||||
uiLang = it == languages.end() ? languages[0] : *it;
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
qDebug() << "bcp47 based languages was" << languages << ", picked" << uiLang;
|
||||
#endif
|
||||
}
|
||||
|
||||
free((void*)prefs.locale.lang_locale);
|
||||
|
|
Loading…
Add table
Reference in a new issue