aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-02-21 13:50:05 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2018-02-26 14:35:21 +0000
commitdb15c3455971f47b86078a44a30e0f0a13b54204 (patch)
tree8bab583a6800074dad8116d74fec29a1f88409c0 /tests
parent3aa73dc00b25aa0c1b85b8b7809a0fd8ad3617a7 (diff)
Fix QQmlEngine::retranslate() with PropertyChanges
When changing the language, we need to re-apply the state of items and re-run the translations if present. Task-number: QTBUG-66541 Change-Id: I83a542af033990ef9a0f92801c5f52d3a5ec722c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmltranslation/data/TranslationChangeBase.qml4
-rw-r--r--tests/auto/qml/qqmltranslation/data/translationChange.qml16
-rw-r--r--tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp2
3 files changed, 19 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmltranslation/data/TranslationChangeBase.qml b/tests/auto/qml/qqmltranslation/data/TranslationChangeBase.qml
index c447c84987..294fff3284 100644
--- a/tests/auto/qml/qqmltranslation/data/TranslationChangeBase.qml
+++ b/tests/auto/qml/qqmltranslation/data/TranslationChangeBase.qml
@@ -1,5 +1,5 @@
-import QtQml 2.0
+import QtQuick 2.0
-QtObject {
+Item {
property string baseProperty: qsTr("translate me");
}
diff --git a/tests/auto/qml/qqmltranslation/data/translationChange.qml b/tests/auto/qml/qqmltranslation/data/translationChange.qml
index 23b87c2493..c48a482138 100644
--- a/tests/auto/qml/qqmltranslation/data/translationChange.qml
+++ b/tests/auto/qml/qqmltranslation/data/translationChange.qml
@@ -1,10 +1,24 @@
-import QtQml 2.0
+import QtQuick 2.0
TranslationChangeBase {
+ id: root
+
baseProperty: "do not translate"
property string text1: qsTr("translate me")
function weDoTranslations() {
return qsTr("translate me")
}
property string text2: weDoTranslations()
+ property string text3
+
+ states: [
+ State {
+ name: "default"
+ when: 1 == 1
+ PropertyChanges {
+ target: root
+ text3: qsTr("translate me")
+ }
+ }
+ ]
}
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
index fc736cde1a..1c67ba5541 100644
--- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
+++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
@@ -194,6 +194,7 @@ void tst_qqmltranslation::translationChange()
QCOMPARE(object->property("baseProperty").toString(), QString::fromUtf8("do not translate"));
QCOMPARE(object->property("text1").toString(), QString::fromUtf8("translate me"));
QCOMPARE(object->property("text2").toString(), QString::fromUtf8("translate me"));
+ QCOMPARE(object->property("text3").toString(), QString::fromUtf8("translate me"));
DummyTranslator translator;
QCoreApplication::installTranslator(&translator);
@@ -204,6 +205,7 @@ void tst_qqmltranslation::translationChange()
QCOMPARE(object->property("baseProperty").toString(), QString::fromUtf8("do not translate"));
QCOMPARE(object->property("text1").toString(), QString::fromUtf8("xxx"));
QCOMPARE(object->property("text2").toString(), QString::fromUtf8("xxx"));
+ QCOMPARE(object->property("text3").toString(), QString::fromUtf8("xxx"));
QCoreApplication::removeTranslator(&translator);
}