mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Work around a Qt Locale bug on Mac
With Qt4.8.5 Locale::uiLanguages() sometimes doesn't return the country, just the language. This works around this by recreating the locale if this has happened. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3b691d5d6e
commit
8bd26af44e
1 changed files with 11 additions and 3 deletions
14
qt-gui.cpp
14
qt-gui.cpp
|
@ -87,21 +87,29 @@ void init_ui(int *argcp, char ***argvp)
|
|||
xslt_path = strdup(getSubsurfaceDataPath("xslt").toAscii().data());
|
||||
|
||||
QLocale loc;
|
||||
QString uiLang = loc.uiLanguages().first();
|
||||
// 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;
|
||||
uiLang = loc2.uiLanguages().first();
|
||||
}
|
||||
|
||||
// we don't have translations for English - if we don't check for this
|
||||
// Qt will proceed to load the second language in preference order - not what we want
|
||||
// on Linux this tends to be en-US, but on the Mac it's just en
|
||||
if (!loc.uiLanguages().first().startsWith("en")) {
|
||||
if (!uiLang.startsWith("en")) {
|
||||
qtTranslator = new QTranslator;
|
||||
if (qtTranslator->load(loc,"qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
|
||||
application->installTranslator(qtTranslator);
|
||||
} else {
|
||||
qDebug() << "can't find Qt localization for locale" << loc.uiLanguages().first();
|
||||
qDebug() << "can't find Qt localization for locale" << uiLang;
|
||||
}
|
||||
ssrfTranslator = new QTranslator;
|
||||
if (ssrfTranslator->load(loc,"subsurface", "_")) {
|
||||
application->installTranslator(ssrfTranslator);
|
||||
} else {
|
||||
qDebug() << "can't find Subsurface localization for locale" << loc.uiLanguages().first();
|
||||
qDebug() << "can't find Subsurface localization for locale" << uiLang;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue