diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-12-09 01:24:08 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-12-09 01:24:08 (GMT) |
commit | 81e855944cecbd0a37bd04c899d71add97a15a65 (patch) | |
tree | 7f56e6f0b5957c29ae4404c73578742e513435e9 /doc/src | |
parent | 06745eba2d7716b03a12b2614a8da74b8a3af858 (diff) | |
download | Qt-81e855944cecbd0a37bd04c899d71add97a15a65.zip Qt-81e855944cecbd0a37bd04c899d71add97a15a65.tar.gz Qt-81e855944cecbd0a37bd04c899d71add97a15a65.tar.bz2 |
Add simple translation example to docs.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/declarative/qmli18n.qdoc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/src/declarative/qmli18n.qdoc b/doc/src/declarative/qmli18n.qdoc index 4b62fcb..0c8b1d1 100644 --- a/doc/src/declarative/qmli18n.qdoc +++ b/doc/src/declarative/qmli18n.qdoc @@ -43,6 +43,8 @@ \page qmli18n.html \title QML Internationalization +\section1 Overview + Strings in QML can be marked for translation using the qsTr(), qsTranslate(), QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions. @@ -63,4 +65,31 @@ capabilities are described more fully in: You can test a translation in \l {qmlviewer} using the -translation option. +\section1 Example + +First we create a simple QML file with text to be translated. The string +that needs to be translated is enclosed in a call to \c qsTr(). + +hello.qml: +\qml +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Text { text: qsTr("Hello"); anchors.centerIn: parent } +} +\endqml + +Next we create a translation source file using lupdate: +\code +lupdate hello.qml -ts hello.ts +\endcode + +Then we open \c hello.ts in \l {Linguist}, provide a translation +and create the release file \c hello.qm. + +Finally, we can test the translation in qmlviewer: +\code +qmlviewer -translation hello.qm hello.qml +\endcode */ |