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)
|
auto it = std::find_if(languages.begin(), languages.end(), [](const QString &s)
|
||||||
{ return s.count('-') == 1; });
|
{ return s.count('-') == 1; });
|
||||||
uiLang = it == languages.end() ? languages[0] : *it;
|
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
|
// there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info
|
||||||
if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) {
|
if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) {
|
||||||
QLocale loc2(loc.bcp47Name());
|
QLocale loc2(loc.bcp47Name());
|
||||||
loc = loc2;
|
loc = loc2;
|
||||||
QStringList languages = loc2.uiLanguages();
|
QStringList languages = loc2.uiLanguages();
|
||||||
if (languages[0].contains('-'))
|
|
||||||
uiLang = languages[0];
|
it = std::find_if(languages.begin(), languages.end(), [](const QString &s)
|
||||||
else if (languages.count() > 1 && languages[1].contains('-'))
|
{ return s.contains('-'); });
|
||||||
uiLang = languages[1];
|
uiLang = it == languages.end() ? languages[0] : *it;
|
||||||
else if (languages.count() > 2 && languages[2].contains('-'))
|
#ifdef SUBSURFACE_MOBILE
|
||||||
uiLang = languages[2];
|
qDebug() << "bcp47 based languages was" << languages << ", picked" << uiLang;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void*)prefs.locale.lang_locale);
|
free((void*)prefs.locale.lang_locale);
|
||||||
|
|
Loading…
Add table
Reference in a new issue