Add I18N support to qmltestrunner
Add a new command line option "-translation file" to handle translation files to qmltestrunner. Task-number:QTBUG-22390 Change-Id: I351ed41734c79a51e00aeef551af642482bf36f2 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
This commit is contained in:
parent
1bc655b467
commit
0339d34691
|
@ -65,6 +65,7 @@
|
||||||
#include <QtGui/qtextdocument.h>
|
#include <QtGui/qtextdocument.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
#include <QtCore/QTranslator>
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,8 +116,10 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
|
||||||
// -import dir Specify an import directory.
|
// -import dir Specify an import directory.
|
||||||
// -input dir Specify the input directory for test cases.
|
// -input dir Specify the input directory for test cases.
|
||||||
// -qtquick1 Run with QtQuick 1 rather than QtQuick 2.
|
// -qtquick1 Run with QtQuick 1 rather than QtQuick 2.
|
||||||
|
// -translation file Specify the translation file.
|
||||||
QStringList imports;
|
QStringList imports;
|
||||||
QString testPath;
|
QString testPath;
|
||||||
|
QString translationFile;
|
||||||
bool qtQuick2 = true;
|
bool qtQuick2 = true;
|
||||||
int outargc = 1;
|
int outargc = 1;
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
@ -132,6 +135,9 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
|
||||||
} else if (strcmp(argv[index], "-qtquick1") == 0) {
|
} else if (strcmp(argv[index], "-qtquick1") == 0) {
|
||||||
qtQuick2 = false;
|
qtQuick2 = false;
|
||||||
++index;
|
++index;
|
||||||
|
} else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
|
||||||
|
translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
|
||||||
|
index += 2;
|
||||||
} else if (outargc != index) {
|
} else if (outargc != index) {
|
||||||
argv[outargc++] = argv[index++];
|
argv[outargc++] = argv[index++];
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,6 +152,15 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
|
||||||
QuickTestResult::parseArgs(argc, argv);
|
QuickTestResult::parseArgs(argc, argv);
|
||||||
QuickTestResult::setProgramName(name);
|
QuickTestResult::setProgramName(name);
|
||||||
|
|
||||||
|
QTranslator translator;
|
||||||
|
if (!translationFile.isEmpty()) {
|
||||||
|
if (translator.load(translationFile)) {
|
||||||
|
app->installTranslator(&translator);
|
||||||
|
} else {
|
||||||
|
qWarning() << "Could not load the translation file" << translationFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determine where to look for the test data.
|
// Determine where to look for the test data.
|
||||||
if (testPath.isEmpty() && sourceDir)
|
if (testPath.isEmpty() && sourceDir)
|
||||||
testPath = QString::fromLocal8Bit(sourceDir);
|
testPath = QString::fromLocal8Bit(sourceDir);
|
||||||
|
|
Loading…
Reference in New Issue