translations: use the right Qt translations (part 2)

It turns out that contrary to what the documentation states, a few languages
are still only using the 'qt' translation. But those exist for all languages,
so we need to first search for the 'qtbase' translations, and only if that
fails do we try to load the 'qt' translations.

And even that will fail for languages in which Qt simply isn't localized (like
Dutch).

To make the code more readable, the check for 'US English' was moved earlier as
there is no point to look for a Qt translation for that (simply doesn't exist).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-09-15 11:54:07 -07:00
parent 1ed8cb373f
commit ff14ca4dd5

View file

@ -86,13 +86,22 @@ void init_qt_late()
#else
translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
if (qtTranslator.load(loc, "qtbase", "_", translationLocation) ||
qtTranslator.load(loc, "qtbase", "_", getSubsurfaceDataPath("translations")) ||
qtTranslator.load(loc, "qtbase", "_", getSubsurfaceDataPath("../translations"))) {
application->installTranslator(&qtTranslator);
} else {
if (uiLang != "en_US" && uiLang != "en-US")
qDebug() << "can't find Qt base localization for locale" << uiLang << "searching in" << translationLocation;
if (uiLang != "en_US" && uiLang != "en-US") {
if (qtTranslator.load(loc, "qtbase", "_", translationLocation) ||
qtTranslator.load(loc, "qtbase", "_", getSubsurfaceDataPath("translations")) ||
qtTranslator.load(loc, "qtbase", "_", getSubsurfaceDataPath("../translations"))) {
application->installTranslator(&qtTranslator);
} else {
// it's possible that this is one of the couple of languages that still have qt_XX translations
// and no qtbase_XX translations - as of this writing this is true for Swedish and Portuguese
if (qtTranslator.load(loc, "qt", "_", translationLocation) ||
qtTranslator.load(loc, "qt", "_", getSubsurfaceDataPath("translations")) ||
qtTranslator.load(loc, "qt", "_", getSubsurfaceDataPath("../translations"))) {
application->installTranslator(&qtTranslator);
} else {
qDebug() << "can't find Qt base localization for locale" << uiLang << "searching in" << translationLocation;
}
}
}
if (ssrfTranslator.load(loc, "subsurface", "_") ||
ssrfTranslator.load(loc, "subsurface", "_", translationLocation) ||