diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-01-05 23:41:30 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-05 23:41:30 -0800 |
commit | 701f91e4fed443aaa52f0199ce4a73f66c4fad74 (patch) | |
tree | 0b19faed0dbc715470e36da2a6c8896deee409e8 | |
parent | e20005ed36e51686b2cfa3b47d26c6fda84f34de (diff) | |
download | subsurface-701f91e4fed443aaa52f0199ce4a73f66c4fad74.tar.gz |
Try harder to find the language name that includes country code
It seems that the first language in the list of languages isn't always the one
that specifies the country code. So try the first three to see which one is the
first to contain a country code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | subsurface-core/qthelper.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index bddfd7608..b89fac4c3 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -839,8 +839,16 @@ QString uiLanguage(QLocale *callerLoc) } else { loc = QLocale(QLocale().uiLanguages().first()); } - - QString uiLang = loc.uiLanguages().first(); + QStringList languages = loc.uiLanguages(); + QString uiLang; + 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]; + else + uiLang = languages[0]; GET_BOOL("time_format_override", time_format_override); GET_BOOL("date_format_override", date_format_override); GET_TXT("time_format", time_format); @@ -852,7 +860,13 @@ QString uiLanguage(QLocale *callerLoc) if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) { QLocale loc2(loc.bcp47Name()); loc = loc2; - uiLang = loc2.uiLanguages().first(); + 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]; } if (callerLoc) *callerLoc = loc; |