source: trunk/doc/src/snippets/code/doc_src_linguist-manual.qdoc

Last change on this file 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: 5.8 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:BSD$
10** You may use this file under the terms of the BSD license as follows:
11**
12** "Redistribution and use in source and binary forms, with or without
13** modification, are permitted provided that the following conditions are
14** met:
15** * Redistributions of source code must retain the above copyright
16** notice, this list of conditions and the following disclaimer.
17** * Redistributions in binary form must reproduce the above copyright
18** notice, this list of conditions and the following disclaimer in
19** the documentation and/or other materials provided with the
20** distribution.
21** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22** the names of its contributors may be used to endorse or promote
23** products derived from this software without specific prior written
24** permission.
25**
26** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41//! [0]
42HEADERS = main-dlg.h \
43 options-dlg.h
44SOURCES = main-dlg.cpp \
45 options-dlg.cpp \
46 main.cpp
47FORMS = search-dlg.ui
48TRANSLATIONS = superapp_dk.ts \
49 superapp_fi.ts \
50 superapp_no.ts \
51 superapp_se.ts
52//! [0]
53
54
55//! [1]
56CODECFORTR = ISO-8859-5
57//! [1]
58
59
60//! [2]
61CODECFORSRC = UTF-8
62//! [2]
63
64
65//! [3]
66label->setText(tr("F\374r \310lise"));
67//! [3]
68
69
70//! [4]
71Usage:
72 lupdate [options] [project-file]
73 lupdate [options] [source-file|path]... -ts ts-files
74Options:
75 -help Display this information and exit.
76 -noobsolete
77 Drop all obsolete strings.
78 -extensions <ext>[,<ext>]...
79 Process files with the given extensions only.
80 The extension list must be separated with commas, not with whitespace.
81 Default: 'ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx'.
82 -pluralonly
83 Only include plural form messages.
84 -silent
85 Do not explain what is being done.
86 -version
87 Display the version of lupdate and exit.
88//! [4]
89
90
91//! [5]
92Usage:
93 lrelease [options] project-file
94 lrelease [options] ts-files [-qm qm-file]
95
96lrelease is part of Qt's Linguist tool chain. It can be used as a
97stand-alone tool to convert XML-based translations files in the TS
98format into the 'compiled' QM format used by QTranslator objects.
99
100Options:
101 -help Display this information and exit
102 -idbased
103 Use IDs instead of source strings for message keying
104 -compress
105 Compress the QM files
106 -nounfinished
107 Do not include unfinished translations
108 -removeidentical
109 If the translated text is the same as
110 the source text, do not include the message
111 -markuntranslated <prefix>
112 If a message has no real translation, use the source text
113 prefixed with the given string instead
114 -silent
115 Do not explain what is being done
116 -version
117 Display the version of lrelease and exit
118//! [5]
119
120
121void wrapInFunction()
122{
123//! [6]
124button = new QPushButton("&Quit", this);
125//! [6]
126
127
128//! [7]
129button = new QPushButton(tr("&Quit"), this);
130//! [7]
131
132
133//! [8]
134QPushButton::tr("&Quit")
135//! [8]
136
137
138//! [9]
139QObject::tr("&Quit")
140//! [9]
141
142
143//! [10]
144rbc = new QRadioButton(tr("Enabled", "Color frame"), this);
145//! [10]
146
147
148//! [11]
149rbh = new QRadioButton(tr("Enabled", "Hue frame"), this);
150//! [11]
151}
152
153
154//! [12]
155/*
156 TRANSLATOR FindDialog
157
158 Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
159 Find dialog.
160
161 ...
162*/
163//! [12]
164
165//! [13]
166/*
167 TRANSLATOR MyNamespace::MyClass
168
169 Necessary for lupdate.
170
171 ...
172*/
173//! [13]
174
175//! [14]
176void some_global_function(LoginWidget *logwid)
177{
178 QLabel *label = new QLabel(
179 LoginWidget::tr("Password:"), logwid);
180}
181
182void same_global_function(LoginWidget *logwid)
183{
184 QLabel *label = new QLabel(
185 qApp->translate("LoginWidget", "Password:"),
186 logwid);
187}
188//! [14]
189
190
191//! [15]
192QString FriendlyConversation::greeting(int greet_type)
193{
194 static const char* greeting_strings[] = {
195 QT_TR_NOOP("Hello"),
196 QT_TR_NOOP("Goodbye")
197 };
198 return tr(greeting_strings[greet_type]);
199}
200//! [15]
201
202
203//! [16]
204static const char* greeting_strings[] = {
205 QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
206 QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
207};
208
209QString FriendlyConversation::greeting(int greet_type)
210{
211 return tr(greeting_strings[greet_type]);
212}
213
214QString global_greeting(int greet_type)
215{
216 return qApp->translate("FriendlyConversation",
217 greeting_strings[greet_type]);
218}
219//! [16]
220
221void wrapInFunction()
222{
223
224//! [17]
225QString tr(const char *text, const char *comment, int n);
226//! [17]
227
228//! [18]
229tr("%n item(s) replaced", "", count);
230//! [18]
231
232}
233
Note: See TracBrowser for help on using the repository browser.