diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-10-16 10:10:04 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-10-28 12:37:05 +0100 |
commit | 05d8ffb4dff5e693967c8ee7cee6d6158eadccbd (patch) | |
tree | f0784506f4575f24062f6a8687ae198d6f635ada | |
parent | 94297b4ca50439d27dd5c3de6ff225185647cc46 (diff) |
Revert: use the new form of QTranslator::load() for more flexibility
This reverts commit 427646b8d7c52e5b84240e07ffd391217ce3bfa8.
It seems that it should have been more correct, but we are still not
shipping English translations, and static QString find_translation()
in qtranslator.cpp will return any language which is in
QLocale::uiLanguages() for which the translation file is found.
That is a long list on OSX.
Reverting the patch means find_translation() is not called in
such cases. This change can be re-done whenever we are more sure
that the attempt to find a translation will succeed in finding a
sensible one, or fall back to not translating, rather than choosing
a language that the user didn't intend.
Task-number: QTBUG-41977
Change-Id: I425946cc71cec96b4f38629eb2b7e80220c5236d
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
-rw-r--r-- | examples/quick/demos/photoviewer/main.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 6 | ||||
-rw-r--r-- | tools/qml/main.cpp | 6 | ||||
-rw-r--r-- | tools/qmlscene/main.cpp | 14 |
4 files changed, 13 insertions, 16 deletions
diff --git a/examples/quick/demos/photoviewer/main.cpp b/examples/quick/demos/photoviewer/main.cpp index 1351f043f3..ca495242a4 100644 --- a/examples/quick/demos/photoviewer/main.cpp +++ b/examples/quick/demos/photoviewer/main.cpp @@ -40,9 +40,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - QLocale locale; QTranslator qtTranslator; - qtTranslator.load(locale, QLatin1String("qml"), QLatin1String("_"), QLatin1String(":/i18n")); + qtTranslator.load("qml_" + QLocale::system().name(), ":/i18n/"); app.installTranslator(&qtTranslator); QQmlApplicationEngine engine; diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index 9ccaee7cd7..240c01233b 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -65,8 +65,7 @@ void QQmlApplicationEnginePrivate::init() q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); #ifndef QT_NO_TRANSLATION QTranslator* qtTranslator = new QTranslator; - QLocale locale; - if (qtTranslator->load(locale, QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) QCoreApplication::installTranslator(qtTranslator); translators << qtTranslator; #endif @@ -83,8 +82,7 @@ void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile) QFileInfo fi(rootFile.toLocalFile()); QTranslator *translator = new QTranslator; - QLocale locale; - if (translator->load(locale, QLatin1String("qml"), QLatin1String("_"), fi.path() + QLatin1String("/i18n"))) { + if (translator->load(QLatin1String("qml_") + QLocale::system().name(), fi.path() + QLatin1String("/i18n"))) { QCoreApplication::installTranslator(translator); translators << translator; } else { diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 7a08562a13..69ccd7a316 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -450,8 +450,10 @@ int main(int argc, char *argv[]) verboseMode = false; #ifndef QT_NO_TRANSLATION - // qt_ translations are loaded by QQmlApplicationEngine - if (!translationFile.isEmpty()) { // Note: installed before QQmlApplicationEngine's automatic translation loading + //qt_ translations loaded by QQmlApplicationEngine + QString sysLocale = QLocale::system().name(); + + if (!translationFile.isEmpty()) { //Note: installed before QQmlApplicationEngine's automatic translation loading QTranslator translator; if (translator.load(translationFile)) { diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index 7c2fd9fc32..208226c8aa 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -307,8 +307,7 @@ static void displayFileDialog(Options *options) #ifndef QT_NO_TRANSLATION static void loadTranslationFile(QTranslator &translator, const QString& directory) { - QLocale locale; - translator.load(locale, QLatin1String("qml"), QLatin1String("_"), directory + QLatin1String("/i18n")); + translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); QCoreApplication::installTranslator(&translator); } #endif @@ -416,18 +415,17 @@ int main(int argc, char ** argv) app.setOrganizationDomain("qt-project.org"); #ifndef QT_NO_TRANSLATION - QLocale locale; + QTranslator translator; QTranslator qtTranslator; - if (qtTranslator.load(locale, QLatin1String("qt"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + QString sysLocale = QLocale::system().name(); + if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(&qtTranslator); - - QTranslator translator; - if (translator.load(locale, QLatin1String("qmlscene"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + if (translator.load(QLatin1String("qmlscene_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(&translator); QTranslator qmlTranslator; if (!options.translationFile.isEmpty()) { - if (qmlTranslator.load(locale, options.translationFile)) { + if (qmlTranslator.load(options.translationFile)) { app.installTranslator(&qmlTranslator); } else { qWarning() << "Could not load the translation file" << options.translationFile; |