summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/component.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2013-06-17 12:40:23 +0200
committerKai Koehne <kai.koehne@digia.com>2013-06-26 11:55:19 +0200
commit5e5c0a10ff9b4cd4f2b1cfdec4f976861b1de160 (patch)
tree756d4870a32bf4dfb75d93ee9b9802e4486b5ba8 /src/libs/installer/component.cpp
parent61ffbff8ab9fcdf8bbc73ee00fb9db7f40e0182b (diff)
Implement dedicated translation settings support.
Change-Id: I41dd23f01e9b511c217fee7f736d9187b8a8623a Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/libs/installer/component.cpp')
-rw-r--r--src/libs/installer/component.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 705fb6d3c..c2cadafc6 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -46,8 +46,9 @@
#include "fsengineclient.h"
#include "globals.h"
#include "lib7z_facade.h"
-#include "packagemanagercore.h"
#include "messageboxhandler.h"
+#include "packagemanagercore.h"
+#include "settings.h"
#include <kdupdaterupdatesourcesinfo.h>
#include <kdupdaterupdateoperationfactory.h>
@@ -516,10 +517,22 @@ void Component::languageChanged()
void Component::loadTranslations(const QDir &directory, const QStringList &qms)
{
QDirIterator it(directory.path(), qms, QDir::Files);
+ const QStringList translations = d->m_core->settings().translations();
+ const QString uiLanguage = QLocale().uiLanguages().value(0, QLatin1String("en_us"))
+ .replace(QLatin1Char('-'), QLatin1Char('_'));
while (it.hasNext()) {
const QString filename = it.next();
- if (QFileInfo(filename).baseName().toLower() != QLocale().name().toLower())
- continue;
+ const QString basename = QFileInfo(filename).baseName();
+ if (!uiLanguage.startsWith(QFileInfo(filename).baseName(), Qt::CaseInsensitive))
+ continue; // do not load the file if it does not match the UI language
+
+ if (!translations.isEmpty()) {
+ bool found = false;
+ foreach (const QString &translation, translations)
+ found |= translation.startsWith(basename, Qt::CaseInsensitive);
+ if (!found) // don't load the file if it does match the UI language but is not allowed to be used
+ continue;
+ }
QScopedPointer<QTranslator> translator(new QTranslator(this));
if (!translator->load(filename))