summaryrefslogtreecommitdiff
path: root/src/controls/plugin.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-09-10 13:55:12 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-09-10 14:37:19 +0200
commit378748b824887a45160219a9345e94e157ed5f89 (patch)
tree1783c022c74f530328289b93f6a61b844709f13b /src/controls/plugin.cpp
parent6a687a818415b68f28de1046c7455c6f934ab6a6 (diff)
downloadqtquickcontrols-378748b824887a45160219a9345e94e157ed5f89.tar.gz
QtQuick.Dialogs: install translator if suitable translations are found
qt_XX.qm is only for Qt 4 compatibility and therefore does not link to qtquickcontrols_XX.qm. The fact that QQmlApplicationEngine loads qt_XX.qm is wrong, insufficient to support dialog translations, and also inefficient in that it loads some translations which we don't need. The loading of relevant translations should be modular along the same lines that Qt is modular. Each Qt module needs to load its own translations. In this case it's needed so that buttons on dialogs will be translated. Dialogs depends on Controls, and the translation file is named as the controls translation file, so any future Controls translations can go here too. It's more efficient to load fewer files than to load separate translations for each QML module. Change-Id: I5fe0c39643f066b15a605b53158e9185792fd33e Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/controls/plugin.cpp')
-rw-r--r--src/controls/plugin.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
index 803c768b..0a652d7f 100644
--- a/src/controls/plugin.cpp
+++ b/src/controls/plugin.cpp
@@ -57,6 +57,11 @@
#include "Private/qquickstyleitem_p.h"
#endif
+#ifndef QT_NO_TRANSLATION
+#include <QtCore/qlibraryinfo.h>
+#include <QtCore/qlocale.h>
+#endif
+
static void initResources()
{
Q_INIT_RESOURCE(controls);
@@ -150,6 +155,12 @@ void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri
engine->addImageProvider("desktoptheme", new QQuickDesktopIconProvider);
if (isLoadedFromResource())
engine->addImportPath(QStringLiteral("qrc:/"));
+
+#ifndef QT_NO_TRANSLATION
+ if (m_translator.load(QLocale(), QLatin1String("qtquickcontrols"),
+ QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ QCoreApplication::installTranslator(&m_translator);
+#endif
}
QString QtQuickControlsPlugin::fileLocation() const