Prevent warnings when English translations can not be load

English translation files are built-in and usually only used
for plural forms. Hence the files are often empty and the
warnings about them are more misleading than helpful most of
the time.

TODO: Find a way to distinguish between translations
which are supposed to be empty and missing/invalid
translations.
This commit is contained in:
Martchus 2017-08-15 01:08:08 +02:00
parent 260b8217da
commit cdd84520da
1 changed files with 18 additions and 11 deletions

View File

@ -123,13 +123,16 @@ void loadQtTranslationFile(initializer_list<QString> repositoryNames, const QStr
} else if (qtTranslator->load(fileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
QCoreApplication::installTranslator(qtTranslator);
} else if (qtTranslator->load(fileName, QStringLiteral("../share/qt/translations"))) {
// used in Windows
QCoreApplication::installTranslator(qtTranslator);
} else if (qtTranslator->load(fileName, QStringLiteral(":/translations"))) {
QCoreApplication::installTranslator(qtTranslator);
} else {
delete qtTranslator;
cerr << "Unable to load translation file for Qt repository \"" << repoName.toLocal8Bit().data() << "\" and language "
if (localeName.startsWith(QLatin1String("en"))) {
// the translation file is probably just empty (English is built-in and usually only used for plural forms)
continue;
}
cerr << "Unable to load translation file for Qt repository \"" << repoName.toLocal8Bit().data() << "\" and locale "
<< localeName.toLocal8Bit().data() << "." << endl;
}
}
@ -196,7 +199,11 @@ void loadApplicationTranslationFile(const QString &applicationName, const QStrin
QCoreApplication::installTranslator(appTranslator);
} else {
delete appTranslator;
cerr << "Unable to load translation file for \"" << applicationName.toLocal8Bit().data() << "\" and the language \""
if (localeName.startsWith(QLatin1String("en"))) {
// the translation file is probably just empty (English is built-in and usually only used for plural forms)
return;
}
cerr << "Unable to load translation file for \"" << applicationName.toLocal8Bit().data() << "\" and the locale \""
<< localeName.toLocal8Bit().data() << "\"." << endl;
}
}