From 61887379b0c823953b61120532055fcbd881aadd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 Jul 2017 14:39:45 +0200 Subject: Add support for QEvent::LanguageChange Respond to the language change event by refreshing all binding expressions. For constant string translation bindings we must now create special QQmlBinding instances instead of a one-time property write meta-call upon instantiation. Those however are more lightweight than an entire JavaScript expression. In addition this provides a slot to explicitly trigger a re-evaluation of bindings, to make it a little easier to discover for the developer. [ChangeLog][QtQml][QQmlEngine] Added retranslate() slot and QEvent::LanguageChange support to refresh bindings when changing the language at run-time. Task-number: QTBUG-15602 Change-Id: Ide174648e1d8a5738acb88e15495018d0869d7bc Reviewed-by: Michael Brasser --- tests/auto/qml/qqmltranslation/data/translationChange.qml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/auto/qml/qqmltranslation/data/translationChange.qml (limited to 'tests/auto/qml/qqmltranslation/data/translationChange.qml') diff --git a/tests/auto/qml/qqmltranslation/data/translationChange.qml b/tests/auto/qml/qqmltranslation/data/translationChange.qml new file mode 100644 index 0000000000..23b87c2493 --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/translationChange.qml @@ -0,0 +1,10 @@ +import QtQml 2.0 + +TranslationChangeBase { + baseProperty: "do not translate" + property string text1: qsTr("translate me") + function weDoTranslations() { + return qsTr("translate me") + } + property string text2: weDoTranslations() +} -- cgit v1.2.3