1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the documentation of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** GNU Free Documentation License
10 ** Alternatively, this file may be used under the terms of the GNU Free
11 ** Documentation License version 1.3 as published by the Free Software
12 ** Foundation and appearing in the file included in the packaging of
16 ** Alternatively, this file may be used in accordance with the terms
17 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
29 \page qdeclarativei18n.html
30 \inqmlmodule QtQuick 1
32 \contentspage QML Features
33 \previouspage {Network Transparency}{Loading Resources in QML}
34 \nextpage {QML Features}
35 \title Qt Quick 1 Internationalization
38 Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
39 QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
43 Text { text: qsTr("Pictures") }
46 These functions are standard QtScript functions; for more details see
47 QScriptEngine::installTranslatorFunctions().
49 QML relies on the core internationalization capabilities provided by Qt. These
50 capabilities are described more fully in:
52 \o \l {Internationalization with Qt}
53 \o \l {Qt Linguist Manual}
56 You can test a translation with the \l {QML Viewer} using the -translation option.
60 First we create a simple QML file with text to be translated. The string
61 that needs to be translated is enclosed in a call to \c qsTr().
68 width: 200; height: 200
69 Text { text: qsTr("Hello"); anchors.centerIn: parent }
73 Next we create a translation source file using lupdate:
75 lupdate hello.qml -ts hello.ts
78 Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
79 a translation and create the release file \c hello.qm.
81 Finally, we can test the translation:
83 qmlviewer -translation hello.qm hello.qml
87 You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}.