ea5b70d0270dfcba5ea911602bec9eb66f3480f1
[profile/ivi/qtdeclarative.git] / doc / src / qtquick1 / 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 1
31 \ingroup qml-features
32 \contentspage QML Features
33 \previouspage {Network Transparency}{Loading Resources in QML}
34 \nextpage {QML Features}
35 \title Qt Quick 1 Internationalization
36
37
38 Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
39 QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
40
41 For example:
42 \qml
43 Text { text: qsTr("Pictures") }
44 \endqml
45
46 These functions are standard QtScript functions; for more details see
47 QScriptEngine::installTranslatorFunctions().
48
49 QML relies on the core internationalization capabilities provided by Qt. These
50 capabilities are described more fully in:
51 \list
52 \o \l {Internationalization with Qt}
53 \o \l {Qt Linguist Manual}
54 \endlist
55
56 You can test a translation with the \l {QML Viewer} using the -translation option.
57
58 \section1 Example
59
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().
62
63 hello.qml:
64 \qml
65 import QtQuick 1.0
66
67 Rectangle {
68     width: 200; height: 200
69     Text { text: qsTr("Hello"); anchors.centerIn: parent }
70 }
71 \endqml
72
73 Next we create a translation source file using lupdate:
74 \code
75 lupdate hello.qml -ts hello.ts
76 \endcode
77
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.
80
81 Finally, we can test the translation:
82 \code
83 qmlviewer -translation hello.qm hello.qml
84 \endcode
85
86
87 You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}.
88 */