19db51fb936833d16d0e3763f45020ae290ee3ce
[profile/ivi/qtdeclarative.git] / doc / src / declarative / qdeclarativei18n.qdoc
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the documentation of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:FDL$
10 ** GNU Free Documentation License
11 ** Alternatively, this file may be used under the terms of the GNU Free
12 ** Documentation License version 1.3 as published by the Free Software
13 ** Foundation and appearing in the file included in the packaging of
14 ** this file.
15 **
16 ** Other Usage
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
19 ** and Nokia.
20 **
21 **
22 **
23 **
24 ** $QT_END_LICENSE$
25 **
26 ****************************************************************************/
27
28 /*!
29 \page qdeclarativei18n.html
30 \inqmlmodule QtQuick 2
31 \ingroup qml-features
32 \contentspage QML Features
33 \previouspage {Network Transparency}{Loading Resources in QML}
34 \nextpage {QML Features}
35 \title QML Internationalization
36
37 \section1 Translation
38
39 Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
40 QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
41
42 For example:
43 \qml
44 Text { text: qsTr("Pictures") }
45 \endqml
46
47 These functions are standard QtScript functions; for more details see
48 QScriptEngine::installTranslatorFunctions().
49
50 QML relies on the core internationalization capabilities provided by Qt. These
51 capabilities are described more fully in:
52 \list
53 \o \l {Internationalization with Qt}
54 \o \l {Qt Linguist Manual}
55 \endlist
56
57 You can test a translation with the \l {QML Viewer} using the -translation option.
58
59 \section2 Example
60
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().
63
64 hello.qml:
65 \qml
66 import QtQuick 2.0
67
68 Rectangle {
69     width: 200; height: 200
70     Text { text: qsTr("Hello"); anchors.centerIn: parent }
71 }
72 \endqml
73
74 Next we create a translation source file using lupdate:
75 \code
76 lupdate hello.qml -ts hello.ts
77 \endcode
78
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.
81
82 Finally, we can test the translation:
83 \code
84 qmlviewer -translation hello.qm hello.qml
85 \endcode
86
87 You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}.
88
89 \section1 Localization
90
91 Localization is the process of adapting to local conventions,
92 for example presenting dates and times using the locally preferred formats.
93
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.
96
97
98 */