source: trunk/doc/src/declarative/qdeclarativei18n.qdoc@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 2.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29\page qdeclarativei18n.html
30\title QML Internationalization
31
32\section1 Overview
33
34Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
35QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
36
37For example:
38\qml
39Text { text: qsTr("Pictures") }
40\endqml
41
42These functions are standard QtScript functions; for more details see
43QScriptEngine::installTranslatorFunctions().
44
45QML relies on the core internationalization capabilities provided by Qt. These
46capabilities are described more fully in:
47\list
48\o \l {Internationalization with Qt}
49\o \l {Qt Linguist Manual}
50\endlist
51
52You can test a translation with the \l {QML Viewer} using the -translation option.
53
54\section1 Example
55
56First we create a simple QML file with text to be translated. The string
57that needs to be translated is enclosed in a call to \c qsTr().
58
59hello.qml:
60\qml
61import QtQuick 1.0
62
63Rectangle {
64 width: 200; height: 200
65 Text { text: qsTr("Hello"); anchors.centerIn: parent }
66}
67\endqml
68
69Next we create a translation source file using lupdate:
70\code
71lupdate hello.qml -ts hello.ts
72\endcode
73
74Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
75a translation and create the release file \c hello.qm.
76
77Finally, we can test the translation:
78\code
79qmlviewer -translation hello.qm hello.qml
80\endcode
81
82
83You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}.
84*/
Note: See TracBrowser for help on using the repository browser.