summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels Weber <niels.weber@digia.com>2013-08-08 16:06:32 +0200
committerNiels Weber <niels.weber@digia.com>2013-08-09 14:44:39 +0200
commit089562c2e7580c9bbb0b266ed374e4a476be1dfb (patch)
tree7d914ee401dc5605c99fa4d30b3e02f9d4ebcfee
parentc0cee088ebe9b1265200dbf74a26e1685c48e4f7 (diff)
Fix selected translation in special circumstances.
In cases where there where multiple uilanguages, sometimes the wrong language was chosen for the Qt localisation. Also, use the standard matching for locales for the ifw translation as well. Task-number: QTIFW-324 Change-Id: I2c4cd079baa3d1ce4c5c69bf6692ba313616f722 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
-rw-r--r--src/sdk/installerbase.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp
index 71f45301e..870182e13 100644
--- a/src/sdk/installerbase.cpp
+++ b/src/sdk/installerbase.cpp
@@ -317,8 +317,16 @@ int main(int argc, char *argv[])
// install the default Qt translator
QScopedPointer<QTranslator> translator(new QTranslator(&app));
- if (translator->load(QLocale(), QLatin1String("qt"), QString::fromLatin1("_"), directory))
- app.installTranslator(translator.take());
+ foreach (const QLocale locale, QLocale().uiLanguages()) {
+ // As there is no qt_en.qm, we simply end the search when the next
+ // preferred language is English.
+ if (locale.language() == QLocale::English)
+ break;
+ if (translator->load(locale, QLatin1String("qt"), QString::fromLatin1("_"), directory)) {
+ app.installTranslator(translator.take());
+ break;
+ }
+ }
translator.reset(new QTranslator(&app));
// install English translation as fallback so that correct license button text is used
@@ -327,10 +335,12 @@ int main(int argc, char *argv[])
if (translations.isEmpty()) {
translator.reset(new QTranslator(&app));
- const QString name = QLocale().uiLanguages().value(0).replace(QLatin1Char('-'), QLatin1Char('_'))
- .toLower(); // install "our" default translator
- if (translator->load(name, directory))
- app.installTranslator(translator.take());
+ foreach (const QLocale locale, QLocale().uiLanguages()) {
+ if (translator->load(locale, QLatin1String(""), QLatin1String(""), directory)) {
+ app.installTranslator(translator.take());
+ break;
+ }
+ }
} else {
foreach (const QString &translation, translations) {
translator.reset(new QTranslator(&app));