diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-18 13:41:04 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-28 15:10:05 +0000 |
commit | 2e17c1bed2f0690342f98130701ebfe088075a60 (patch) | |
tree | 1a5d21784a7dbebe6d53a5b9c29a6a29c83a5c25 /tests | |
parent | 7f93ecd31494d17351ff8e16820b7117aa07d90b (diff) |
Fix language change support for qsTr in ListElement
We must store translations by binding reference in order to support
translation changes. This is similar to commit
db15c3455971f47b86078a44a30e0f0a13b54204.
[ChangeLog][QtQml] Fix QQmlEngine::retranslate() with ListElement
objects that use translation functions such as qsTr.
Task-number: QTBUG-68350
Change-Id: Ie5b4d5beb0505a260b524da820c0ce1142893d54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmltranslation/data/translationChange.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltranslation/data/translationChange.qml b/tests/auto/qml/qqmltranslation/data/translationChange.qml index c48a482138..ae3231935c 100644 --- a/tests/auto/qml/qqmltranslation/data/translationChange.qml +++ b/tests/auto/qml/qqmltranslation/data/translationChange.qml @@ -3,6 +3,13 @@ import QtQuick 2.0 TranslationChangeBase { id: root + ListModel { + id: listModel + ListElement { + text: qsTr("translate me") + } + } + baseProperty: "do not translate" property string text1: qsTr("translate me") function weDoTranslations() { @@ -10,6 +17,7 @@ TranslationChangeBase { } property string text2: weDoTranslations() property string text3 + property string fromListModel: listModel.get(0).text states: [ State { diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp index 733fe77346..5042a236d4 100644 --- a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp +++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp @@ -195,6 +195,7 @@ void tst_qqmltranslation::translationChange() 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")); + QCOMPARE(object->property("fromListModel").toString(), QString::fromUtf8("translate me")); DummyTranslator translator; QCoreApplication::installTranslator(&translator); @@ -206,6 +207,7 @@ void tst_qqmltranslation::translationChange() QCOMPARE(object->property("text1").toString(), QString::fromUtf8("xxx")); QCOMPARE(object->property("text2").toString(), QString::fromUtf8("xxx")); QCOMPARE(object->property("text3").toString(), QString::fromUtf8("xxx")); + QCOMPARE(object->property("fromListModel").toString(), QString::fromUtf8("xxx")); QCoreApplication::removeTranslator(&translator); } |