1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

[Translations] Correctly load translation for non-translated countries

Closes #1152
This commit is contained in:
nowrep 2014-01-17 21:39:02 +01:00
parent fc7b289be2
commit bcaecbdde1

View File

@ -762,6 +762,19 @@ void MainApplication::translateApp()
file.append(".qm");
}
// If "xx_yy" translation doesn't exists, try to use "xx*" translation
// It can only happen when Language is chosen from system locale
if (!file.isEmpty() && !QFile(TRANSLATIONSDIR + QLatin1String("/") + file).exists()) {
QDir translationsDir(TRANSLATIONSDIR);
QString lang = file.left(2) + QLatin1String("*.qm");
const QStringList translations = translationsDir.entryList(QStringList(lang));
// If no translation can be found, default English will be used
file = translations.isEmpty() ? QString() : translations.first();
}
QTranslator* app = new QTranslator(this);
app->load(file, TRANSLATIONSDIR);