From dce65c258373f06c0f3ba6029a4c6da251aa33ee Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 4 Feb 2020 08:52:00 +0100 Subject: Provide a means to use fixed translations for Qt and IFW Since building Qt statically and then IFW can be seen as a lot to do just to be able to provide a fixed translation for a Qt or IFW string then it is better to provide a means to override these translations. So if a translation is found inside :/translations_new then it will use this one instead of the one found at :/translations for Qt or IFW strings. This can be provided via the -r option when using binarycreator then. Change-Id: I007c45ff96ccf5d73b54a5df8a80a2a05c2f35c6 Reviewed-by: Katja Marttila --- src/sdk/installerbase.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index e6cf150ca..7613d12f4 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -272,12 +272,18 @@ int InstallerBase::run() } const QString directory = QLatin1String(":/translations"); + // Check if there is a modified translation first to enable people + // to easily provide corrected translations to Qt/IFW for their installers + const QString newDirectory = QLatin1String(":/translations_new"); const QStringList translations = m_core->settings().translations(); if (translations.isEmpty()) { foreach (const QLocale locale, QLocale().uiLanguages()) { QScopedPointer qtTranslator(new QTranslator(QCoreApplication::instance())); - const bool qtLoaded = qtTranslator->load(locale, QLatin1String("qt"), + bool qtLoaded = qtTranslator->load(locale, QLatin1String("qt"), + QLatin1String("_"), newDirectory); + if (!qtLoaded) + qtLoaded = qtTranslator->load(locale, QLatin1String("qt"), QLatin1String("_"), directory); if (qtLoaded || locale.language() == QLocale::English) { @@ -285,7 +291,10 @@ int InstallerBase::run() QCoreApplication::instance()->installTranslator(qtTranslator.take()); QScopedPointer ifwTranslator(new QTranslator(QCoreApplication::instance())); - if (ifwTranslator->load(locale, QLatin1String("ifw"), QLatin1String("_"), directory)) + bool ifwLoaded = ifwTranslator->load(locale, QLatin1String("ifw"), QLatin1String("_"), newDirectory); + if (!ifwLoaded) + ifwLoaded = ifwTranslator->load(locale, QLatin1String("ifw"), QLatin1String("_"), directory); + if (ifwLoaded) QCoreApplication::instance()->installTranslator(ifwTranslator.take()); // To stop loading other translations it's sufficient that -- cgit v1.2.3