summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2020-01-30 11:08:50 +0100
committerKai Koehne <kai.koehne@qt.io>2020-02-10 15:14:55 +0000
commite541a3f099798e2258116d3c031b35274d789783 (patch)
treea4f51d14629083f331151001d629629af4050284 /tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
parentdce61f04503d6730b954b153395cc3f9ce5d7c24 (diff)
QTranslator: Expose language of translation file
This allows for instance to show the current UI language in the UI, or to load additional translations that match the .qm file by other means. This is especially useful in the case of QTranslator::load(QLocale(), ...), in which case different language and country combinations might be tried. Another option is to inspect the file name via QTranslator::filePath(); however, this is more error-prone, and might also miss information (if the .qm file name doesn't have a country suffix, or no suffix at all). Change-Id: I6f565d53d8f50e21241ccae6c4de264747ac8f81 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp')
-rw-r--r--tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
index cc0f97139f..9fde7da816 100644
--- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp
@@ -110,9 +110,10 @@ void tst_QTranslator::load_data()
QTest::addColumn<QString>("filepath");
QTest::addColumn<bool>("isEmpty");
QTest::addColumn<QString>("translation");
+ QTest::addColumn<QString>("language");
- QTest::newRow("hellotr_la") << "hellotr_la.qm" << false << "Hallo Welt!";
- QTest::newRow("hellotr_empty") << "hellotr_empty.qm" << true << "";
+ QTest::newRow("hellotr_la") << "hellotr_la.qm" << false << "Hallo Welt!" << "de";
+ QTest::newRow("hellotr_empty") << "hellotr_empty.qm" << true << "" << "";
}
void tst_QTranslator::load()
@@ -120,6 +121,7 @@ void tst_QTranslator::load()
QFETCH(QString, filepath);
QFETCH(bool, isEmpty);
QFETCH(QString, translation);
+ QFETCH(QString, language);
{
QTranslator tor;
@@ -127,6 +129,7 @@ void tst_QTranslator::load()
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
QCOMPARE(tor.filePath(), filepath);
+ QCOMPARE(tor.language(), language);
}
{
@@ -138,6 +141,7 @@ void tst_QTranslator::load()
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
QCOMPARE(tor.filePath(), "");
+ QCOMPARE(tor.language(), language);
}
{
@@ -147,6 +151,7 @@ void tst_QTranslator::load()
QCOMPARE(tor.isEmpty(), isEmpty);
QCOMPARE(tor.translate("QPushButton", "Hello world!"), translation);
QCOMPARE(tor.filePath(), path);
+ QCOMPARE(tor.language(), language);
}
}