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 2
32 \contentspage QML Features
33 \previouspage {Network Transparency}{Loading Resources in QML}
34 \nextpage {QML Features}
35 \title QML Internationalization
39 Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
40 QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
44 Text { text: qsTr("Pictures") }
47 These functions are standard QtScript functions; for more details see
48 QScriptEngine::installTranslatorFunctions().
50 QML relies on the core internationalization capabilities provided by Qt. These
51 capabilities are described more fully in:
53 \o \l {Internationalization with Qt}
54 \o \l {Qt Linguist Manual}
57 You can test a translation with the \l {QML Viewer} using the -translation option.
61 First we create a simple QML file with text to be translated. The string
62 that needs to be translated is enclosed in a call to \c qsTr().
69 width: 200; height: 200
70 Text { text: qsTr("Hello"); anchors.centerIn: parent }
74 Next we create a translation source file using lupdate:
76 lupdate hello.qml -ts hello.ts
79 Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
80 a translation and create the release file \c hello.qm.
82 Finally, we can test the translation:
84 qmlviewer -translation hello.qm hello.qml
87 You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}.
89 \section1 Localization
91 Localization is the process of adapting to local conventions,
92 for example presenting dates and times using the locally preferred formats.
94 Qt Quick supports localization via the \l {QtQuick2::Locale}{Locale} object and extensions to the
95 ECMAScript \l {QtQuick2::Date}{Date} and \l {QtQuick2::Number}{Number} types.