QML InternationalizationStrings in QML can be marked for translation using the qsTr(), qsTranslate(), QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions. For example: Text { text: qsTr("Pictures") } These functions are standard QtScript functions; for more details see QScriptEngine::installTranslatorFunctions(). QML relies on the core internationalization capabilities provided by Qt. These capabilities are described more fully in: You can test a translation with the QML Viewer using the -translation option. ExampleFirst we create a simple QML file with text to be translated. The string that needs to be translated is enclosed in a call to qsTr(). hello.qml: import QtQuick 1.0 Rectangle { width: 200; height: 200 Text { text: qsTr("Hello"); anchors.centerIn: parent } } Next we create a translation source file using lupdate: lupdate hello.qml -ts hello.ts Then we open hello.ts in Linguist, provide a translation and create the release file hello.qm. Finally, we can test the translation: qmlviewer -translation hello.qm hello.qml You can see a complete example and source code in the QML Internationalization example. [Previous: Loading Resources in QML] [Next: QML Features] © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. |