diff options
author | Katja Marttila <katja.marttila@qt.io> | 2021-09-23 15:02:41 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2021-10-12 15:49:21 +0300 |
commit | 899de36a0dabdda432809b480dbac0b42afe5723 (patch) | |
tree | 23dcd0b096d4a8e5ad2c8148f5840783f55d7323 | |
parent | aca6df782c09235aef02cf4a5d33bc3890079bd8 (diff) |
Add ability to query used language in script
Task-number: QTIFW-2208
Change-Id: I8c8e9bd798320ab6d4397ac411cfea75177d27f2
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r-- | doc/scripting.qdoc | 3 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/sdk/sdkapp.h | 11 |
3 files changed, 10 insertions, 5 deletions
diff --git a/doc/scripting.qdoc b/doc/scripting.qdoc index 517eec941..1310253a0 100644 --- a/doc/scripting.qdoc +++ b/doc/scripting.qdoc @@ -317,6 +317,9 @@ For example, \c {C:\ProgramData\Microsoft\Windows\Start Menu\Programs} Only available on Windows. + \row + \li UILanguage + \li The language that is used in the installer. \endtable The variables can be resolved by calls to installer::value(). If embedded diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index 0e16d4c4b..61efe98a8 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -40,6 +40,7 @@ static const QLatin1String scFalse("false"); static const QLatin1String scScript("script"); static const QLatin1String scAllUsersStartMenuProgramsPath("AllUsersStartMenuProgramsPath"); static const QLatin1String scUserStartMenuProgramsPath("UserStartMenuProgramsPath"); +static const QLatin1String scUILanguage("UILanguage"); static const QLatin1String scName("Name"); static const QLatin1String scVersion("Version"); diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h index 1e6580fef..60eca8103 100644 --- a/src/sdk/sdkapp.h +++ b/src/sdk/sdkapp.h @@ -196,7 +196,7 @@ public: QInstaller::Protocol::Mode::Production, userArgs, isCommandLineInterface); } - QLocale::Language lang = QLocale::AnyLanguage; + QLocale lang = QLocale::English; #ifndef IFW_DISABLE_TRANSLATIONS if (!isCommandLineInterface) { const QString directory = QLatin1String(":/translations"); @@ -227,7 +227,7 @@ public: // To stop loading other translations it's sufficient that // qt was loaded successfully or we hit English as system language - lang = locale.language(); + lang = locale; break; } } @@ -238,7 +238,7 @@ public: QCoreApplication::instance()->installTranslator(translator.take()); } QLocale currentLocale(translations.at(0).section(QLatin1Char('_'), 1)); - lang = currentLocale.language(); + lang = currentLocale; } } #endif @@ -397,8 +397,9 @@ public: errorMessage = e.message(); return false; } - if (lang != QLocale::AnyLanguage) - emit m_core->defaultTranslationsLoadedForLanguage(lang); + + m_core->setValue(QInstaller::scUILanguage, lang.name()); + emit m_core->defaultTranslationsLoadedForLanguage(lang.language()); ProductKeyCheck::instance()->addPackagesFromXml(QLatin1String(":/metadata/Updates.xml")); return true; |