0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the documentation of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
/*!
|
|
43 |
\page linguist-manual.html
|
|
44 |
\title Qt Linguist Manual
|
|
45 |
\ingroup qttools
|
|
46 |
|
|
47 |
\startpage {index.html}{Qt Reference Documentation}
|
|
48 |
\nextpage Qt Linguist Manual: Release Manager
|
|
49 |
|
|
50 |
\keyword Qt Linguist
|
|
51 |
|
|
52 |
Qt provides excellent support for translating applications into local
|
|
53 |
languages. This Guide explains how to use Qt's translation tools for
|
|
54 |
each of the roles involved in translating an application. The Guide
|
|
55 |
begins with a brief overview of the issues that must be considered,
|
|
56 |
followed by chapters devoted to each role and the supporting tools
|
|
57 |
provided.
|
|
58 |
|
|
59 |
The \l{linguist-manager.html}{Release Manager} chapter is aimed
|
|
60 |
at the person with overall responsibility for the release of the
|
|
61 |
application. They will typically coordinate the work of the
|
|
62 |
software engineers and the translator. The chapter describes the
|
|
63 |
use of two tools. The \l{lupdate} tool is used to synchronize
|
|
64 |
source code and translations. The \l{lrelease} tool is used to
|
|
65 |
create runtime translation files for use by the released
|
|
66 |
application.
|
|
67 |
|
|
68 |
The \l{linguist-translators.html}{Translators} chapter is for
|
|
69 |
translators. It describes the use of the \QL tool.
|
|
70 |
No computer knowledge beyond the ability to start a program and
|
|
71 |
use a text editor or word processor is required.
|
|
72 |
|
|
73 |
The \l{linguist-programmers.html}{Programmers} chapter is for Qt
|
|
74 |
programmers. It explains how to create Qt applications that are
|
|
75 |
able to use translated text. It also provides guidance on how to
|
|
76 |
help the translator identify the context in which phrases appear.
|
|
77 |
This chapter's three short tutorials cover everything the
|
|
78 |
programmer needs to do.
|
|
79 |
|
|
80 |
\section1 Overview of the Translation Process
|
|
81 |
|
|
82 |
Most of the text that must be translated in an application program
|
|
83 |
consists of either single words or short phrases. These typically
|
|
84 |
appear as window titles, menu items, pop-up help text (balloon help),
|
|
85 |
and labels to buttons, check boxes and radio buttons.
|
|
86 |
|
|
87 |
The phrases are entered into the source code by the programmer in
|
|
88 |
their native language using a simple but special syntax to identify
|
|
89 |
that the phrases require translation. The Qt tools provide context
|
|
90 |
information for each of the phrases to help the translator, and the
|
|
91 |
programmer is able to add additional context information to phrases
|
|
92 |
when necessary. The release manager generates a set of translation
|
|
93 |
files that are produced from the source files and passes these to the
|
|
94 |
translator. The translator opens the translation files using \QL,
|
|
95 |
enters their translations and saves the results back into
|
|
96 |
the translation files, which they pass back to the release manager.
|
|
97 |
The release manager then generates fast compact versions of these
|
|
98 |
translation files ready for use by the application. The tools are
|
|
99 |
designed to be used in repeated cycles as applications change and
|
|
100 |
evolve, preserving existing translations and making it easy to
|
|
101 |
identify which new translations are required. \QL also
|
|
102 |
provides a phrase book facility to help ensure consistent
|
|
103 |
translations across multiple applications and projects.
|
|
104 |
|
|
105 |
Translators and programmers must address a number of issues because
|
|
106 |
of the subtleties and complexities of human language:
|
|
107 |
|
|
108 |
\list
|
|
109 |
|
|
110 |
\o A single phrase may need to be translated into several
|
|
111 |
different forms depending on context, e.g. \e open in English
|
|
112 |
might become \e{\ouml\c{}ffnen}, "open file", or \e aufbauen,
|
|
113 |
"open internet connection", in German.
|
|
114 |
|
|
115 |
\o Keyboard accelerators may need to be changed but without
|
|
116 |
introducing conflicts, e.g. "\&Quit" in English becomes "Avslutt"
|
|
117 |
in Norwegian which doesn't contain a "Q". We cannot use a letter
|
|
118 |
that is already in use - unless we change several accelerators.
|
|
119 |
|
|
120 |
\o Phrases that contain variables, for example, "The 25 files
|
|
121 |
selected will take 63 seconds to process", where the two numbers
|
|
122 |
are inserted programmatically at runtime may need to be reworded
|
|
123 |
because in a different language the word order and therefore the
|
|
124 |
placement of the variables may have to change.
|
|
125 |
|
|
126 |
\endlist
|
|
127 |
|
|
128 |
The Qt translation tools provide clear and simple solutions to these
|
|
129 |
issues.
|
|
130 |
|
|
131 |
Chapters:
|
|
132 |
|
|
133 |
\list
|
|
134 |
\o \l{Qt Linguist Manual: Release Manager}{Release Manager}
|
|
135 |
\o \l{Qt Linguist Manual: Translators}{Translators}
|
|
136 |
\o \l{Qt Linguist Manual: Programmers}{Programmers}
|
|
137 |
\o \l{Qt Linguist Manual: TS File Format}{TS File Format}
|
|
138 |
\endlist
|
|
139 |
|
|
140 |
\QL and \c lupdate are able to import and export XML Localization
|
|
141 |
Interchange File Format (XLIFF) files, making it possible to take
|
|
142 |
advantage of tools and translation services that work with this
|
|
143 |
format. See the \l{Qt Linguist Manual: Translators} {Translators}
|
|
144 |
section for more information on working with these files.
|
|
145 |
|
|
146 |
\table
|
|
147 |
|
|
148 |
\row \o{1,2} \inlineimage wVista-Cert-border-small.png
|
|
149 |
\o \e{Qt Linguist 4.3 is Certified for Windows Vista}
|
|
150 |
|
|
151 |
\row \o Windows Vista and the Windows Vista Start button are
|
|
152 |
trademarks or registered trademarks of Microsoft Corporation in
|
|
153 |
the United States and/or other countries.
|
|
154 |
|
|
155 |
\endtable
|
|
156 |
*/
|
|
157 |
|
|
158 |
/*!
|
|
159 |
\page linguist-manager.html
|
|
160 |
\title Qt Linguist Manual: Release Manager
|
|
161 |
|
|
162 |
\contentspage {Qt Linguist Manual}{Contents}
|
|
163 |
\previouspage Qt Linguist Manual
|
|
164 |
\nextpage Qt Linguist Manual: Translators
|
|
165 |
|
|
166 |
\keyword lupdate
|
|
167 |
\keyword lrelease
|
|
168 |
|
|
169 |
Two tools are provided for the release manager, \l lupdate and \l
|
|
170 |
lrelease. These tools can process \l qmake project files, or operate
|
|
171 |
directly on the file system.
|
|
172 |
|
|
173 |
\section1 Qt Project Files
|
|
174 |
|
|
175 |
The easiest method to use \l{#lupdate} {lupdate} and \l{#lrelease}
|
|
176 |
{lrelease} is by specifing a \c .pro Qt project file. There must
|
|
177 |
be an entry in the \c TRANSLATIONS section of the project file for
|
|
178 |
each language that is additional to the native language. A typical
|
|
179 |
entry looks like this:
|
|
180 |
|
|
181 |
\snippet examples/linguist/arrowpad/arrowpad.pro 1
|
|
182 |
|
|
183 |
Using a locale within the translation file name is useful for
|
|
184 |
determining which language to load at runtime. This is explained
|
|
185 |
in the \l{linguist-programmers.html} {Programmers} chapter.
|
|
186 |
|
|
187 |
An example of a complete \c .pro file with four translation source
|
|
188 |
files:
|
|
189 |
|
|
190 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 0
|
|
191 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 1
|
|
192 |
|
|
193 |
QTextCodec::setCodecForTr() makes it possible to choose a 8-bit
|
|
194 |
encoding for literal strings that appear within \c tr() calls.
|
|
195 |
This is useful for applications whose source language is, for
|
|
196 |
example, Chinese or Japanese. If no encoding is set, \c tr() uses
|
|
197 |
Latin1.
|
|
198 |
|
|
199 |
If you do use the QTextCodec::codecForTr() mechanism in your
|
|
200 |
application, \QL needs you to set the \c CODECFORTR
|
|
201 |
entry in the \c .pro file as well. For example:
|
|
202 |
|
|
203 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 1
|
|
204 |
|
|
205 |
Also, if your compiler uses a different encoding for its runtime
|
|
206 |
system as for its source code and you want to use non-ASCII
|
|
207 |
characters in string literals, you will need to set the \c
|
|
208 |
CODECFORSRC. For example:
|
|
209 |
|
|
210 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 2
|
|
211 |
|
|
212 |
Microsoft Visual Studio 2005 .NET appears to be the only compiler
|
|
213 |
for which this is necessary. However, if you want to write
|
|
214 |
portable code, we recommend that you avoid non-ASCII characters
|
|
215 |
in your source files. You can still specify non-ASCII characters
|
|
216 |
portably using escape sequences, for example:
|
|
217 |
|
|
218 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 3
|
|
219 |
|
|
220 |
\target lupdate manual
|
|
221 |
\section1 lupdate
|
|
222 |
|
|
223 |
Usage: \c {lupdate myproject.pro}
|
|
224 |
|
|
225 |
\l lupdate is a command line tool that finds the translatable
|
|
226 |
strings in the specified source, header and \e {Qt Designer}
|
|
227 |
interface files, and produces or updates \c .ts translation
|
|
228 |
files. The files to process and the files to update can be set at
|
|
229 |
the command line, or provided in a \c .pro file specified as an
|
|
230 |
command line argument. The produced translation files are given to
|
|
231 |
the translator who uses \QL to read the files and insert the
|
|
232 |
translations.
|
|
233 |
|
|
234 |
Companies that have their own translators in-house may find it
|
|
235 |
useful to run \l lupdate regularly, perhaps monthly, as the
|
|
236 |
application develops. This will lead to a fairly low volume of
|
|
237 |
translation work spread evenly over the life of the project and
|
|
238 |
will allow the translators to support a number of projects
|
|
239 |
simultaneously.
|
|
240 |
|
|
241 |
Companies that hire in translators as required may prefer to run
|
|
242 |
\l lupdate only a few times in the application's life cycle, the
|
|
243 |
first time might be just before the first test phase. This will
|
|
244 |
provide the translator with a substantial single block of work and
|
|
245 |
any bugs that the translator detects may easily be included with
|
|
246 |
those found during the initial test phase. The second and any
|
|
247 |
subsequent \l lupdate runs would probably take place during the
|
|
248 |
final beta phase.
|
|
249 |
|
|
250 |
The TS file format is a simple human-readable XML format that
|
|
251 |
can be used with version control systems if required. \c lupdate
|
|
252 |
can also process Localization Interchange File Format (XLIFF)
|
|
253 |
format files; files in this format typically have file names that
|
|
254 |
end with the \c .xlf suffix.
|
|
255 |
|
|
256 |
Pass the \c -help option to \c lupdate to obtain the list of
|
|
257 |
supported options:
|
|
258 |
|
|
259 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 4
|
|
260 |
|
|
261 |
\QL is also able to import and export XLIFF files. See the
|
|
262 |
\l{Qt Linguist Manual: Translators}{Translators} section for more
|
|
263 |
information.
|
|
264 |
|
|
265 |
\section1 lrelease
|
|
266 |
|
|
267 |
Usage: \c {lrelease myproject.pro}
|
|
268 |
|
|
269 |
\l lrelease is a command line tool that produces QM files out
|
|
270 |
of TS files. The QM file format is a compact binary format
|
|
271 |
that is used by the localized application. It provides extremely
|
|
272 |
fast lookups for translations. The TS files \l lrelease
|
|
273 |
processes can be specified at the command line, or given
|
|
274 |
indirectly by a Qt \c .pro project file.
|
|
275 |
|
|
276 |
This tool is run whenever a release of the application is to be
|
|
277 |
made, from initial test version through to final release
|
|
278 |
version. If the QM files are not created, e.g. because an
|
|
279 |
alpha release is required before any translation has been
|
|
280 |
undertaken, the application will run perfectly well using the text
|
|
281 |
the programmers placed in the source files. Once the QM files
|
|
282 |
are available the application will detect them and use them
|
|
283 |
automatically.
|
|
284 |
|
|
285 |
Note that lrelease will only incorporate translations that are
|
|
286 |
marked as "finished". Otherwise the original text will be used
|
|
287 |
instead.
|
|
288 |
|
|
289 |
Pass the \c -help option to \c lrelease to obtain the list of
|
|
290 |
supported options:
|
|
291 |
|
|
292 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 5
|
|
293 |
|
|
294 |
\section1 Missing Translations
|
|
295 |
|
|
296 |
Both \l lupdate and \l lrelease may be used with TS
|
|
297 |
translation source files which are incomplete. Missing
|
|
298 |
translations will be replaced with the native language phrases at
|
|
299 |
runtime.
|
|
300 |
*/
|
|
301 |
|
|
302 |
/*!
|
|
303 |
\page linguist-translators.html
|
|
304 |
\title Qt Linguist Manual: Translators
|
|
305 |
|
|
306 |
\contentspage {Qt Linguist Manual}{Contents}
|
|
307 |
\previouspage Qt Linguist Manual: Release Manager
|
|
308 |
\nextpage Qt Linguist Manual: Programmers
|
|
309 |
|
|
310 |
Contents
|
|
311 |
|
|
312 |
\tableofcontents
|
|
313 |
|
|
314 |
\section1 The One Minute Guide to Using Qt Linguist
|
|
315 |
|
|
316 |
\QL is a tool for adding translations to Qt applications. Run \QL
|
|
317 |
from the taskbar menu, or by double clicking the desktop icon, or
|
|
318 |
by entering the command \c {linguist} at the command line. Once
|
|
319 |
\QL has started, choose \menu{File|Open} from the \l{menubar}
|
|
320 |
{menu bar} and select a translation source (TS file) to
|
|
321 |
load. If you do not have a TS file, see the \l {Qt Linguist
|
|
322 |
Manual: Release Manager} {release manager manual} to learn how to
|
|
323 |
generate one.
|
|
324 |
|
|
325 |
The \QL main window is divided into several, dockable subwindows
|
|
326 |
arranged around a central \l{The Translation Area} {translation
|
|
327 |
area}. The \l{Context Window} {context list} is normally shown
|
|
328 |
on the left, and the \l{Sources and Forms Window} {source code},
|
|
329 |
\l{Strings Window} {string list}, and either the \l{Phrases and
|
|
330 |
Guesses Window} {phrases and guesses}, or the \l{Warnings Window}
|
|
331 |
{warnings} are shown above and below the \l{The Translation Area}
|
|
332 |
{translations area}.
|
|
333 |
|
|
334 |
With a translation file loaded, select a context from the
|
|
335 |
\l{Context Window} {context list} on the left. Selecting a context
|
|
336 |
loads the translatable strings found in that context into the
|
|
337 |
\l{Strings Window} {string list}. Selecting one of the strings
|
|
338 |
copies that string as the \key{Source text} in the \l{The
|
|
339 |
Translation Area} {translation area}. Click in the text entry
|
|
340 |
widget below the copied string and type your translation for that
|
|
341 |
string. To accept the translation, either press the green
|
|
342 |
\key{tick mark} button on the toolbar, or click the icon to the
|
|
343 |
left of the selected source string in the string list. Repeat this
|
|
344 |
process until all strings in the string list are marked with
|
|
345 |
\inlineimage linguist-check-on.png
|
|
346 |
or
|
|
347 |
\inlineimage linguist-check-warning.png
|
|
348 |
. Then select the next context and continue.
|
|
349 |
|
|
350 |
Translation options are shown in the \l{Phrases and Guesses
|
|
351 |
Window} {phrases and guesses window}. If the phrases and guesses
|
|
352 |
window is not visible, click the \key{Phrases and guesses} tab at
|
|
353 |
the bottom of the main window. The phrases and guesses window
|
|
354 |
shows possible translations for the current string. These
|
|
355 |
translation "guesses" have been read from phrase books
|
|
356 |
(\menu{Phrases|Open Phrase Book...}). The current string's
|
|
357 |
current translation is also shown here. To select a guess, double
|
|
358 |
click it in the phrases and guesses window or use the keyboard
|
|
359 |
shortcut shown to the right of the guess.
|
|
360 |
|
|
361 |
\QL can automatically check whether your translation strings pass
|
|
362 |
a list of \l{Validation Tests} {validation tests}. Validation test
|
|
363 |
failures are shown in the \l{Warnings Window} {warnings window}.
|
|
364 |
If the warnings window is not visible, click the \key{Warnings}
|
|
365 |
tab at the bottom of the main window.
|
|
366 |
|
|
367 |
Finally, if the source code for the contexts is accessible, the
|
|
368 |
\l{Sources and Forms Window} {source code window} shows the
|
|
369 |
context where the current string is used. If the source code
|
|
370 |
window is not visible, click the \key{Sources and Forms} tab at
|
|
371 |
the bottom of the main window.
|
|
372 |
|
|
373 |
At the end of the session choose \menu{File|Save} from the menu
|
|
374 |
bar and then \menu{File|Exit} to quit.
|
|
375 |
|
|
376 |
\section1 The Qt Linguist Window
|
|
377 |
|
|
378 |
\image linguist-linguist.png "Linguist UI Snapshot"
|
|
379 |
|
|
380 |
This \QL main window is divided into dockable subwindows arranged
|
|
381 |
around a central \l{The Translation Area} {translation area}. The
|
|
382 |
subwindows are: \l{Context Window} {Context}, \l{Sources and Forms
|
|
383 |
Window} {Sources and Forms}, \l{Strings Window} {Strings},
|
|
384 |
\l{Phrases and Guesses Window} {Phrases and guesses}, and
|
|
385 |
\l{Warnings Window} {Warnings} (hidden in the UI snapsot). The
|
|
386 |
translation area is always visible, but the dockable subwindows
|
|
387 |
can be activated or deactivated in the \menu{View|Views} menu, and
|
|
388 |
dragged around by their title bars and dropped in the translation
|
|
389 |
area or even outside the main window.
|
|
390 |
|
|
391 |
\section2 Context Window
|
|
392 |
|
|
393 |
The context window normally appears on the left side of the main
|
|
394 |
window. It lists the contexts in which strings to be translated
|
|
395 |
appear. The column labeled \e{Context} lists the context names in
|
|
396 |
alphabetical order. Each context is the name of a subclass of
|
|
397 |
QObject. There can also be a context for QObject itself, which
|
|
398 |
contains strings passed to the static function QObject::tr().
|
|
399 |
There can also be an \e{<unnamed context>}, which contains strings
|
|
400 |
that aren't in a subclass of QObject.
|
|
401 |
|
|
402 |
To the left of the \e{Context} column is a column labeled
|
|
403 |
\inlineimage linguist-check-obsolete.png
|
|
404 |
. This column uses the following list of icons to summarize the
|
|
405 |
current translation state for each context:
|
|
406 |
|
|
407 |
\list
|
|
408 |
|
|
409 |
\o \inlineimage linguist-check-on.png
|
|
410 |
All strings in the context have been translated, and all the
|
|
411 |
translations passed the \l{Validation Tests} {validation tests}.
|
|
412 |
|
|
413 |
\o \inlineimage linguist-check-warning.png
|
|
414 |
All strings in the context have been translated or marked as
|
|
415 |
translated, but at least one translation failed the \l{Validation
|
|
416 |
Tests} {validation tests}.
|
|
417 |
|
|
418 |
\o \inlineimage linguist-check-off.png
|
|
419 |
At least one string in the context has not been translated or is
|
|
420 |
not marked as translated.
|
|
421 |
|
|
422 |
\o \inlineimage linguist-check-obsolete.png
|
|
423 |
None of the translated strings still appears in the context. This
|
|
424 |
usually means the context itself no longer exists in the
|
|
425 |
application.
|
|
426 |
|
|
427 |
\endlist
|
|
428 |
|
|
429 |
To the right of the \e{Context} column is the \e{Items} column.
|
|
430 |
Each entry in the \e{Items} column is a pair of numbers separated
|
|
431 |
by a slash ("/"). The number to the right of the slash is the
|
|
432 |
number of translatable strings in the context. The number to the
|
|
433 |
left of the slash is the number of those strings that currently
|
|
434 |
have translations. i.e., if the numbers are equal, all the
|
|
435 |
translatable strings in the context have translations.
|
|
436 |
|
|
437 |
In the UI snapshot above, the \bold{MessageEditor} context is
|
|
438 |
selected. Its \e{Items} entry shows \bold{18/18}, which means it
|
|
439 |
has 18 translatable strings and all 18 strings currently have
|
|
440 |
translations. However, the context has been marked with the
|
|
441 |
\inlineimage linguist-check-warning.png
|
|
442 |
icon, which means that at least one of the current translations
|
|
443 |
failed a \l{Validation Tests} {validation test}. In the
|
|
444 |
\l{Strings Window} {strings window} to the right, we see that one
|
|
445 |
of the strings is indeed marked with the
|
|
446 |
\inlineimage linguist-check-warning.png
|
|
447 |
icon.
|
|
448 |
|
|
449 |
The context window is a dockable window. It can be dragged to
|
|
450 |
another position in the main window, or dragged out of the main
|
|
451 |
window to be a separate window. If you move the context window,
|
|
452 |
\QL remembers the new position and puts the context window there
|
|
453 |
whenever you start the program. If the context window has been
|
|
454 |
closed, it can be restored by pressing \key{F6}.
|
|
455 |
|
|
456 |
\section2 Strings Window
|
|
457 |
|
|
458 |
The strings window normally appears on the right in the main
|
|
459 |
window, above the \l{The Translation Area} {translation area}. Its
|
|
460 |
\e{Source text} column lists all the translatable strings found in
|
|
461 |
the current context. Selecting a string makes that string the
|
|
462 |
current string in the \l{The Translation Area} {translation area}.
|
|
463 |
|
|
464 |
To the left of the \e{Source text} column is a column labeled
|
|
465 |
\inlineimage linguist-check-obsolete.png
|
|
466 |
. This column is similar to the one in the \l{Context Window}
|
|
467 |
{context window}, but here you can click on the icon to change the
|
|
468 |
translation acceptance state for each string in the list. A tick
|
|
469 |
mark, green or yellow, means the string has been translated and
|
|
470 |
the user has accepted the translation. A question mark means
|
|
471 |
either that the user has not accepted the string's translation or
|
|
472 |
that the string doesn't have a translation. The table below
|
|
473 |
explains the acceptance states and their icons:
|
|
474 |
|
|
475 |
\target String Translation States
|
|
476 |
|
|
477 |
\table
|
|
478 |
\header
|
|
479 |
\o State
|
|
480 |
\o Icon
|
|
481 |
\o Description
|
|
482 |
|
|
483 |
\row
|
|
484 |
\o Accepted/Correct
|
|
485 |
\o \inlineimage linguist-check-on.png
|
|
486 |
\o The source string has a translation (possibly empty); the user
|
|
487 |
has accepted the translation, and the translation passes all the
|
|
488 |
\l{Validation Tests} {validation tests}. If the translation is
|
|
489 |
empty, the user has chosen to leave it empty. Click the icon to
|
|
490 |
revoke acceptance of the translation and decrement the number of
|
|
491 |
accepted translations in the \e{Items} column of the \l{Context
|
|
492 |
Window} {context list} by 1. The state is reset to
|
|
493 |
\inlineimage linguist-check-off.png
|
|
494 |
if the string has a translation, or to
|
|
495 |
\inlineimage linguist-check-empty.png
|
|
496 |
if the string's translation is empty. If \c{lupdate} changes the
|
|
497 |
contents of a string, its acceptance state is automatically reset
|
|
498 |
to \inlineimage linguist-check-off.png
|
|
499 |
.
|
|
500 |
|
|
501 |
\row
|
|
502 |
\o Accepted/Warnings
|
|
503 |
\o \inlineimage linguist-check-warning.png
|
|
504 |
\o The user has accepted the translation, but the translation does
|
|
505 |
not pass all the \l{Validation Tests} {validation tests}. The
|
|
506 |
validation test failures are shown in the \l{Warnings Window}
|
|
507 |
{warnings window}. Click the icon to revoke acceptance of the
|
|
508 |
translation. The state is reset to \inlineimage linguist-danger.png
|
|
509 |
, and the number of accepted translations in the \e{Items} column
|
|
510 |
of the \l{Context Window} {context list} is decremented by 1.
|
|
511 |
|
|
512 |
\row
|
|
513 |
\o Not Accepted
|
|
514 |
\o \inlineimage linguist-check-off.png
|
|
515 |
\o The string has a non-empty translation that passes all the
|
|
516 |
\l{Validation Tests} {validation tests}, but the user has not yet
|
|
517 |
accepted the translation. Click the icon or press \key{Ctrl+Enter}
|
|
518 |
to accept the translation. The state is reset to
|
|
519 |
\inlineimage linguist-check-on.png
|
|
520 |
, and the number of accepted translations in the \e{Items} column
|
|
521 |
of the \l{Context Window} {context list} is incremented by 1.
|
|
522 |
|
|
523 |
\row
|
|
524 |
\o No Translation
|
|
525 |
\o \inlineimage linguist-check-empty.png
|
|
526 |
\o The string does not have a translation. Click the icon to
|
|
527 |
accpet the empty translation anyway. The state is reset to
|
|
528 |
\inlineimage linguist-check-on.png
|
|
529 |
, and the number of accepted translations in the \e{Items} column
|
|
530 |
of the \l{Context Window} {context list} is incremented by 1.
|
|
531 |
|
|
532 |
\row
|
|
533 |
\o Validation Failures
|
|
534 |
\o \inlineimage linguist-danger.png
|
|
535 |
\o The string has a translation, but the translation does not
|
|
536 |
pass all the \l{Validation Tests} {validation tests}. Validation
|
|
537 |
test failures are shown in the \l{Warnings Window} {warnings}
|
|
538 |
window. Click on the icon or press \key{Ctrl+Return} to accept
|
|
539 |
the translation even with validation failures. The state is
|
|
540 |
reset to \inlineimage linguist-check-warning.png
|
|
541 |
. We recommended editing the translation to fix the causes of
|
|
542 |
the validation failures. The state will reset automatically to
|
|
543 |
\inlineimage linguist-check-off.png
|
|
544 |
, when all the failures have been fixed.
|
|
545 |
|
|
546 |
\row
|
|
547 |
\o Obsolete
|
|
548 |
\o \inlineimage linguist-check-obsolete.png
|
|
549 |
\o The string is obsolete. It is no longer used in the context.
|
|
550 |
See the \l{Qt Linguist Manual: Release Manager} {Release Manager}
|
|
551 |
for instructions on how to remove obsolete messages from the file.
|
|
552 |
|
|
553 |
\endtable
|
|
554 |
|
|
555 |
The string list is a dockable subwindow. If it has been closed,
|
|
556 |
restored it by pressing \key{F7}.
|
|
557 |
|
|
558 |
\section2 The Translation Area
|
|
559 |
|
|
560 |
The translation area is in the middle of the main window, to the
|
|
561 |
right of the \l{Context Window} {context list}. It doesn't have a
|
|
562 |
title bar, so you can't drag it around. Instead, you drag and drop
|
|
563 |
the other subwindows to arrange them around the translation area.
|
|
564 |
The string currently selected in the \l{Strings Window} {string
|
|
565 |
list} appears at the top of the translation area, under the label
|
|
566 |
\menu{Source text}. Note that all blanks in the source text have
|
|
567 |
been replaced by "." so the translator can see the spacing
|
|
568 |
required within the text.
|
|
569 |
|
|
570 |
If the developer provides a \l{QObject::tr()} {disambiguating
|
|
571 |
comment}, it will appear below the source text area, under the
|
|
572 |
label \menu{Developer comments}.
|
|
573 |
|
|
574 |
Below the source text and optional developer comments are two text
|
|
575 |
entry widgets for the translator, one for entering the translation
|
|
576 |
of the current string, and one for the translator to enter an
|
|
577 |
optional comment to be read by other translators.
|
|
578 |
|
|
579 |
When \l{Translating Multiple Languages Simultaneously} {multiple
|
|
580 |
languages} are being translated, this sequence of fields is
|
|
581 |
repeated for each language. See aso \l {Changing the Target
|
|
582 |
Locale}.
|
|
583 |
|
|
584 |
\section2 Phrases and Guesses Window
|
|
585 |
|
|
586 |
If the current string in the \l{Strings Window} {string list}
|
|
587 |
appears in one or more of the \l{Phrase Books} {phrase books}
|
|
588 |
that have been loaded, the current string and its phrase book
|
|
589 |
translation(s) will be listed in this window. If the current
|
|
590 |
string is the same as, or similar to, another string that has
|
|
591 |
already been translated, that other string and its translation
|
|
592 |
will also be listed in this window.
|
|
593 |
|
|
594 |
To use a translation from the Phrases and Guesses Window, you can
|
|
595 |
double click the translation, and it will be copied into the
|
|
596 |
translation area, or you can use the translation's \e{Guess}
|
|
597 |
hotkey on the right. You can also press \key{F10} to move the
|
|
598 |
focus to the Phrases and Guesses Window, then use the up and down
|
|
599 |
arrow keys to find the desired translation, and and then press
|
|
600 |
\key{Enter} to copy it to the translation area. If you decide
|
|
601 |
that you don't want to copy a phrase after all, press \key{Esc} to
|
|
602 |
return the focus to the translation area.
|
|
603 |
|
|
604 |
The Phrases and Guesses Window is a dockable window. If it has
|
|
605 |
been closed, it can be made visible by pressing the \e{Phrases and
|
|
606 |
guesses} tab at the bottom of the window, or by pressing
|
|
607 |
\key{F10}.
|
|
608 |
|
|
609 |
\section2 Sources and Forms Window
|
|
610 |
|
|
611 |
If the source files containing the translatable strings are
|
|
612 |
available to \QL, this window shows the source context of the
|
|
613 |
current string in the \l{Strings Window} {string list}. The source
|
|
614 |
code line containing the current string should be shown and
|
|
615 |
highlighted. If the file containing the source string is not
|
|
616 |
found, the expected absolute file path is shown.
|
|
617 |
|
|
618 |
If the source context shows the wrong source line, it probably
|
|
619 |
means the translation file is out of sync with the source files.
|
|
620 |
To re-sync the translation file with the source files, see the
|
|
621 |
\l{lupdate manual} {lupdate manual}.
|
|
622 |
|
|
623 |
The Sources and Forms window is a dockable window. If it has been
|
|
624 |
closed, it can be made visible again by pressing the \e{Sources
|
|
625 |
and Forms} tab at the bottom of the window, or by pressing
|
|
626 |
\key{F9}.
|
|
627 |
|
|
628 |
\section2 Warnings Window
|
|
629 |
|
|
630 |
If the translation you enter for the current string fails any of
|
|
631 |
the active \l{Validation Tests} {validation tests}, the failures
|
|
632 |
are listed in the warnings window. The first of these failure
|
|
633 |
messages is also shown in the status bar at the bottom of the main
|
|
634 |
window. Note that only \e{active} validation tests are
|
|
635 |
reported. To see which validation tests are currently active, or
|
|
636 |
to activate or deactivate tests, use the \menu{Validation} menu
|
|
637 |
from the \l{menubar}{menu bar}.
|
|
638 |
|
|
639 |
The Warnings window is a dockable window. If it has been closed,
|
|
640 |
it can be made visible by pressing the \e{Warnings} tab at the
|
|
641 |
bottom of the window, or by pressing \key{F8}.
|
|
642 |
|
|
643 |
\target multiple languages
|
|
644 |
\section2 Translating Multiple Languages Simultaneously
|
|
645 |
|
|
646 |
Qt Linguist can now load and edit multiple translation files
|
|
647 |
simultaneously. One use for this is the case where you know two
|
|
648 |
languages better than you know English (Polish and Japanese, say),
|
|
649 |
and you are given an application's Polish translation file and
|
|
650 |
asked to update the application's Japanese translation file. You
|
|
651 |
are more comfortable translating Polish to Japanese than you are
|
|
652 |
translating English to Japanese.
|
|
653 |
|
|
654 |
Below is the UI snapshot shown earlier, but this time with both
|
|
655 |
\e{Polish} and \e{Japanese} translation files loaded.
|
|
656 |
|
|
657 |
\image linguist-linguist_2.png
|
|
658 |
|
|
659 |
The first thing to notice is that the \l{The Translation Area}
|
|
660 |
{translation area} has text editing areas for both Polish and
|
|
661 |
Japanese, and these are color-coded for easier separation.
|
|
662 |
Second, the \l{Context Window} and the \l{Strings Window} both
|
|
663 |
have two clomuns labeled \inlineimage linguist-check-obsolete.png
|
|
664 |
instead of one, and although it may be hard to tell, these columns
|
|
665 |
are also color-coded with the same colors. The left-most column in
|
|
666 |
either case applies to the top-most language area (Polish above)
|
|
667 |
in the \l{The Translation Area} {translation area}, and the
|
|
668 |
right-most column applies to the bottom language area.
|
|
669 |
|
|
670 |
The \e{Items} column in the \l{Context Window} combines the values
|
|
671 |
for both languages. The best way to see this is to look at the
|
|
672 |
value for the \bold{MessageEditor} context, which is the one
|
|
673 |
selected in the snapshot shown above. Recall that in the first UI
|
|
674 |
snapshot (Polish only), the numbers for this context were
|
|
675 |
\e{18/18}, meaning 18 translatable strings had been found in the
|
|
676 |
context, and all 18 strings had accepted translations. In the UI
|
|
677 |
snapshot above, the numbers for the \bold{MessageEditor} context
|
|
678 |
are now \e{1/18}, meaning that both languages have 18 translatable
|
|
679 |
strings for that context, but for Japanese, only 1 of the 18
|
|
680 |
strings has an accepted translation. The
|
|
681 |
\inlineimage linguist-check-off.png
|
|
682 |
icon in the Japanese column means that at least one string in the
|
|
683 |
context doesn't have an accepted Japanese translation yet. In fact,
|
|
684 |
17 of the 18 strings don't have accepted Japanese translations yet.
|
|
685 |
We will see \e{18/18} in the \e{Items} column when all 18 strings
|
|
686 |
have accepted translations for all the loaded translation files,
|
|
687 |
e.g., both Polish and Japanese in the snapshot.
|
|
688 |
|
|
689 |
\section1 Common Tasks
|
|
690 |
|
|
691 |
\section2 Leaving a Translation for Later
|
|
692 |
|
|
693 |
If you wish to leave a translation press \key{Ctrl+L} (Next
|
|
694 |
Unfinished) to move to the next unfinished translation. To move to
|
|
695 |
the next translation (whether finished or unfinished) press
|
|
696 |
\key{Shift+Ctrl+L}. You can also navigate using the Translation
|
|
697 |
menu. If you want to go to a different context entirely, click the
|
|
698 |
context you want to work on in the Context list, then click the
|
|
699 |
source text in the \l{Strings Window} {string list}.
|
|
700 |
|
|
701 |
\section2 Phrases That Require Multiple Translations Depending on Context
|
|
702 |
|
|
703 |
The same phrase may occur in two or more contexts without conflict. Once
|
|
704 |
a phrase has been translated in one context, \QL notes
|
|
705 |
that the translation has been made and when the translator reaches a
|
|
706 |
later occurrence of the same phrase \QL will provide
|
|
707 |
the previous translation as a possible translation candidate in the
|
|
708 |
\l{Phrases and Guesses Window}.
|
|
709 |
|
|
710 |
If a phrase occurs more than once in a particular context it will
|
|
711 |
only be shown once in \QL's \l{Context Window} {context list} and
|
|
712 |
the translation will be applied to every occurrence within the
|
|
713 |
context. If the same phrase needs to be translated differently
|
|
714 |
within the same context the programmer must provide a
|
|
715 |
distinguishing comment for each of the phrases concerned. If such
|
|
716 |
comments are used the duplicate phrases will appear in the
|
|
717 |
\l{Context Window} {context list}. The programmers comments will
|
|
718 |
appear in the \l{The Translation Area} {translation area} on a
|
|
719 |
light blue background.
|
|
720 |
|
|
721 |
\section2 Changing Keyboard Accelerators
|
|
722 |
|
|
723 |
A keyboard accelerator is a key combination that, when pressed,
|
|
724 |
causes an application to perform an action. There are two kinds of
|
|
725 |
keyboard accelerators: Alt key and Ctrl key accelerators.
|
|
726 |
|
|
727 |
\section3 Alt Key Accellerators
|
|
728 |
|
|
729 |
Alt key accelerators are used in menu selection and on buttons.
|
|
730 |
The underlined character in a menu item or button label signifies
|
|
731 |
that pressing the Alt key with the underlined character will
|
|
732 |
perform the same action as clicking the menu item or pressing the
|
|
733 |
button. For example, most applications have a \e{File} menu with
|
|
734 |
the "F" in the word "File" underlined. In these applications the
|
|
735 |
\e{File} menu can be invoked either by clicking the word "File" on
|
|
736 |
the menu bar or by pressing \e{Alt+F}. To identify an accelerator
|
|
737 |
key in the translation text ("File") precede it with an ampersand,
|
|
738 |
e.g. \e{\&File}. If a string to be translated has an ampersand in
|
|
739 |
it, then the translation for that string should also have an
|
|
740 |
ampersand in it, preferably in front of the same character.
|
|
741 |
|
|
742 |
The meaning of an Alt key accelerator can be determined from the
|
|
743 |
phrase in which the ampersand is embedded. The translator can
|
|
744 |
change the character part of the Alt key accelerator, if the
|
|
745 |
translated phrase does not contain the same character or if that
|
|
746 |
character has already been used in the translation of some other
|
|
747 |
Alt key accelerator. Conflicts with other Alt key accelerators
|
|
748 |
must be avoided within a context. Note that some Alt key
|
|
749 |
accelerators, usually those on the menu bar, may apply in other
|
|
750 |
contexts.
|
|
751 |
|
|
752 |
\section3 Ctrl Key Accelerators
|
|
753 |
|
|
754 |
Ctrl key accelerators can exist independently of any visual
|
|
755 |
control. They are often used to invoke actions in menus that would
|
|
756 |
otherwise require multiple keystrokes or mouse clicks. They may
|
|
757 |
also be used to perform actions that do not appear in any menu or
|
|
758 |
on any button. For example, most applications that have a \e{File}
|
|
759 |
menu have a \e{New} submenu item in the \e{File} menu. The \e{New}
|
|
760 |
item might appear as "\underline{N}ew Ctrl+N" in the \e{File}
|
|
761 |
menu, meaning the \e{New} menu can be invoked by simply pressing
|
|
762 |
\key{Ctrl+N}, instead of either clicking \e{File} with the mouse
|
|
763 |
and then clicking \e{New} with the mouse, or by entering \e{Alt+F}
|
|
764 |
and \e{N}.
|
|
765 |
|
|
766 |
Each Ctrl key accelerator is shown in the \l{Strings Window}
|
|
767 |
{string list} as a separate string, e.g. \key{Ctrl+Enter}. Since
|
|
768 |
the string doesn't have a context to give it meaning, e.g. like
|
|
769 |
the context of the phrase in which an Alt key accelerator appears,
|
|
770 |
the translator must rely on the UI developer to include a
|
|
771 |
\l{QObject::tr()} {disambiguation comment} to explain the action
|
|
772 |
the Ctrl key accelerator is meant to perform. This disambiguating
|
|
773 |
comment (if provided by the developer) will appear under
|
|
774 |
\e{Developer comments} in the \l{The Translation Area}
|
|
775 |
{translation area} under the \e{Source text} area.
|
|
776 |
|
|
777 |
Ideally Ctrl key accelerators are translated simply by copying
|
|
778 |
them directly using \e {Copy from source text} in the
|
|
779 |
\menu{Translation} menu. However, in some cases the character will
|
|
780 |
not make sense in the target language, and it must be
|
|
781 |
changed. Whichever character (alpha or digit) is chosen, the
|
|
782 |
translation must be in the form "Ctrl+" followed by the upper case
|
|
783 |
character. \e{Qt} will automatically display the correct name at
|
|
784 |
runtime. As with Alt key accelerators, if the translator changes
|
|
785 |
the character, the new character must not conflict with any other
|
|
786 |
Ctrl key accelerator.
|
|
787 |
|
|
788 |
\warning Do not translate the "Alt", "Ctrl" or "Shift" parts of
|
|
789 |
the accelerators. \e{Qt} relies on these strings being there. For
|
|
790 |
supported languages, \e {Qt} automatically translates these
|
|
791 |
strings.
|
|
792 |
|
|
793 |
\section2 Handling Numbered Arguments
|
|
794 |
|
|
795 |
Some phrases contain numbered arguments. A numbered argument is a
|
|
796 |
placeholder that will be replaced with text at runtime. A numbered
|
|
797 |
argument appears in a source string as a percent sign followed by
|
|
798 |
a digit. Consider an example: \c{After processing file %1, file %2
|
|
799 |
is next in line}. In this string to be translated, \c{%1} and
|
|
800 |
\c{%2} are numbered arguments. At runtime, \c{%1} and \c{%2} will
|
|
801 |
be replaced with the first and next file names respectively. The
|
|
802 |
same numbered arguments must appear in the translation, but not
|
|
803 |
necessarily in the same order. A German translation of the string
|
|
804 |
might reverse the phrases, e.g. \c{Datei %2 wird bearbeitet, wenn
|
|
805 |
Datei %1 fertig ist}. Both numbered arguments appear in the
|
|
806 |
translation, but in the reverse order. \c{%i} will always be
|
|
807 |
replaced by the same text in the translation stringss, regardless
|
|
808 |
of where argument \e{i} appears in the argument sequence in the
|
|
809 |
source string.
|
|
810 |
|
|
811 |
\section2 Plurals
|
|
812 |
|
|
813 |
The problem of plurals in output is resolved by using an overload of
|
|
814 |
the \c tr() function with the signature
|
|
815 |
\code
|
|
816 |
QString tr(const char *text, const char *comment, int n);
|
|
817 |
\endcode
|
|
818 |
Using built in comparisons for the value of \c n the tr() function will
|
|
819 |
translate the phrase to the plural form for the target language.
|
|
820 |
|
|
821 |
Different languages have various forms for plurals beyond simply
|
|
822 |
\e singular and \e plural. The rules for determining which form of the
|
|
823 |
plural to use are encoded as conditional tests. Below is a table
|
|
824 |
representing the numbers associated with the forms rather than the
|
|
825 |
conditional tests themselves.
|
|
826 |
|
|
827 |
|
|
828 |
|
|
829 |
\table 90%
|
|
830 |
\header
|
|
831 |
\o Language
|
|
832 |
\o Form 1
|
|
833 |
\o Form 2
|
|
834 |
\o Form 3
|
|
835 |
\o Form 4
|
|
836 |
\row
|
|
837 |
\o Arabic
|
|
838 |
\o 0, 1, 11-102, 111-202...
|
|
839 |
\o 2
|
|
840 |
\o 3-10, 103-110, 203-210...
|
|
841 |
\o
|
|
842 |
\row
|
|
843 |
\o Basque
|
|
844 |
\o 1
|
|
845 |
\o 0, 2-100, 101-
|
|
846 |
\o
|
|
847 |
\o
|
|
848 |
\row
|
|
849 |
\o Bulgarian
|
|
850 |
\o 1
|
|
851 |
\o 0, 2-100, 101-
|
|
852 |
\o
|
|
853 |
\o
|
|
854 |
\row
|
|
855 |
\o Catalan
|
|
856 |
\o 1
|
|
857 |
\o 11, 11 000-11 999, 11 000 000-11 999 999...
|
|
858 |
\o 0, 2-10, 12-10 999, 12-10 999 999...
|
|
859 |
\o
|
|
860 |
\row
|
|
861 |
\o Chinese-CN
|
|
862 |
\o 0-
|
|
863 |
\o
|
|
864 |
\o
|
|
865 |
\o
|
|
866 |
\row
|
|
867 |
\o Chinese-HK
|
|
868 |
\o 0-
|
|
869 |
\o
|
|
870 |
\o
|
|
871 |
\o
|
|
872 |
\row
|
|
873 |
\o Chinese-TW
|
|
874 |
\o 0-
|
|
875 |
\o
|
|
876 |
\o
|
|
877 |
\o
|
|
878 |
\row
|
|
879 |
\o Croation
|
|
880 |
\o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101...
|
|
881 |
\o 2-4, 22-24, 32-34, 42-44...
|
|
882 |
\o 0, 5-20, 25-30, 35-40...
|
|
883 |
\o
|
|
884 |
\row
|
|
885 |
\o Czech
|
|
886 |
\o 1
|
|
887 |
\o 2-4
|
|
888 |
\o 0, 5-
|
|
889 |
\o
|
|
890 |
\row
|
|
891 |
\o Danish
|
|
892 |
\o 1
|
|
893 |
\o 0, 2-100, 101-
|
|
894 |
\o
|
|
895 |
\o
|
|
896 |
\row
|
|
897 |
\o Dutch
|
|
898 |
\o 1
|
|
899 |
\o 0, 2-100, 101-
|
|
900 |
\o
|
|
901 |
\o
|
|
902 |
\row
|
|
903 |
\o English
|
|
904 |
\o 1
|
|
905 |
\o 0, 2-100, 101-
|
|
906 |
\o
|
|
907 |
\o
|
|
908 |
\row
|
|
909 |
\o English-US
|
|
910 |
\o 1
|
|
911 |
\o 0, 2-100, 101-
|
|
912 |
\o
|
|
913 |
\o
|
|
914 |
\row
|
|
915 |
\o Estonian
|
|
916 |
\o 1
|
|
917 |
\o 0, 2-100, 101-
|
|
918 |
\o
|
|
919 |
\o
|
|
920 |
\row
|
|
921 |
\o Finnish
|
|
922 |
\o 1
|
|
923 |
\o 0, 2-100, 101-
|
|
924 |
\o
|
|
925 |
\o
|
|
926 |
\row
|
|
927 |
\o French-CA
|
|
928 |
\o 0, 1
|
|
929 |
\o 2-100, 101-
|
|
930 |
\o
|
|
931 |
\o
|
|
932 |
\row
|
|
933 |
\o French-FR
|
|
934 |
\o 0, 1
|
|
935 |
\o 2-100, 101-
|
|
936 |
\o
|
|
937 |
\o
|
|
938 |
\row
|
|
939 |
\o Galician
|
|
940 |
\o 1
|
|
941 |
\o 0, 2-100, 101-
|
|
942 |
\o
|
|
943 |
\o
|
|
944 |
\row
|
|
945 |
\o German
|
|
946 |
\o 1
|
|
947 |
\o 0, 2-100, 101-
|
|
948 |
\o
|
|
949 |
\o
|
|
950 |
\row
|
|
951 |
\o Greek
|
|
952 |
\o 1
|
|
953 |
\o 0, 2-100, 101-
|
|
954 |
\o
|
|
955 |
\o
|
|
956 |
\row
|
|
957 |
\o Hebrew
|
|
958 |
\o 1
|
|
959 |
\o 0, 2-100, 101-
|
|
960 |
\o
|
|
961 |
\o
|
|
962 |
\row
|
|
963 |
\o
|
|
964 |
\o 1
|
|
965 |
\o 0, 2-100, 101-
|
|
966 |
\o
|
|
967 |
\o
|
|
968 |
\row
|
|
969 |
\o Hungarian
|
|
970 |
\o 0-
|
|
971 |
\o
|
|
972 |
\o
|
|
973 |
\o
|
|
974 |
\row
|
|
975 |
\o Icelandic
|
|
976 |
\o 1, 21, 31, 41, 51....101, 121, 131...
|
|
977 |
\o 0, 2-20, 22-30, 32-40...102-120...
|
|
978 |
\o
|
|
979 |
\o
|
|
980 |
\row
|
|
981 |
\o Indonesian
|
|
982 |
\o 0-
|
|
983 |
\o
|
|
984 |
\o
|
|
985 |
\o
|
|
986 |
\row
|
|
987 |
\o Italian
|
|
988 |
\o 1
|
|
989 |
\o 0, 2-100, 101-
|
|
990 |
\o
|
|
991 |
\o
|
|
992 |
\row
|
|
993 |
\o Japanese
|
|
994 |
\o 0-
|
|
995 |
\o
|
|
996 |
\o
|
|
997 |
\o
|
|
998 |
\row
|
|
999 |
\o Korean
|
|
1000 |
\o 0-
|
|
1001 |
\o
|
|
1002 |
\o
|
|
1003 |
\o
|
|
1004 |
\row
|
|
1005 |
\o Latvian
|
|
1006 |
\o 0
|
|
1007 |
\o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 131, 141...
|
|
1008 |
\o 2-20, 22-30, 32-40, 42-50...202-220, 222-230...
|
|
1009 |
\o
|
|
1010 |
\row
|
|
1011 |
\o Lithuanian
|
|
1012 |
\o 1, 21, 31, 41, 51...101, 121, 131...
|
|
1013 |
\o 2-9, 22-29, 32-39...102-109, 122-129, 132-139...
|
|
1014 |
\o 0, 10-20, 30, 40, 50...110-120, 130, 140...
|
|
1015 |
\o
|
|
1016 |
\row
|
|
1017 |
\o Malay
|
|
1018 |
\o 0-
|
|
1019 |
\o
|
|
1020 |
\o
|
|
1021 |
\o
|
|
1022 |
\row
|
|
1023 |
\o Norwegian
|
|
1024 |
\o 1
|
|
1025 |
\o 0, 2-100, 101-
|
|
1026 |
\o
|
|
1027 |
\o
|
|
1028 |
\row
|
|
1029 |
\o Persian
|
|
1030 |
\o 0-
|
|
1031 |
\o
|
|
1032 |
\o
|
|
1033 |
\o
|
|
1034 |
\row
|
|
1035 |
\o Polish
|
|
1036 |
\o 1
|
|
1037 |
\o 2-4, 22-24, 32-34...
|
|
1038 |
\o 5-21, 25-31, 35-41...
|
|
1039 |
\o
|
|
1040 |
\row
|
|
1041 |
\o Portugese-BR
|
|
1042 |
\o 0, 1
|
|
1043 |
\o 2-100, 101-
|
|
1044 |
\o
|
|
1045 |
\o
|
|
1046 |
\row
|
|
1047 |
\o Portugese-PT
|
|
1048 |
\o 1
|
|
1049 |
\o 0, 2-100, 101-
|
|
1050 |
\o
|
|
1051 |
\o
|
|
1052 |
\row
|
|
1053 |
\o Romanian
|
|
1054 |
\o 1
|
|
1055 |
\o 0, 2-19, 101-119, 201-219...
|
|
1056 |
\o 20-100, 120-200, 220-300...
|
|
1057 |
\o
|
|
1058 |
\row
|
|
1059 |
\o Russian
|
|
1060 |
\o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101...
|
|
1061 |
\o 2-4, 22-24, 32-34...
|
|
1062 |
\o 0, 5-20, 25-30, 35-40...
|
|
1063 |
\o
|
|
1064 |
\row
|
|
1065 |
\o Serbian
|
|
1066 |
\o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101...
|
|
1067 |
\o 2-4, 22-24, 32-34...
|
|
1068 |
\o 0, 5-20, 25-30, 35-40...
|
|
1069 |
\o
|
|
1070 |
\row
|
|
1071 |
\o Slovak
|
|
1072 |
\o 1
|
|
1073 |
\o 2-4
|
|
1074 |
\o 0, 5-20, 25-30, 35-40...
|
|
1075 |
\o
|
|
1076 |
\row
|
|
1077 |
\o Slovene
|
|
1078 |
\o 1, 101, 201, 301...
|
|
1079 |
\o 2, 102, 202, 302...
|
|
1080 |
\o 3, 4, 103, 104, 203, 204, 303, 304...
|
|
1081 |
\o 0, 5-100, 105-200, 205-300...
|
|
1082 |
\row
|
|
1083 |
\o Spanish-US
|
|
1084 |
\o 1
|
|
1085 |
\o 0, 2-
|
|
1086 |
\o
|
|
1087 |
\o
|
|
1088 |
\row
|
|
1089 |
\o Spanish-ES
|
|
1090 |
\o 1
|
|
1091 |
\o 0, 2-
|
|
1092 |
\o
|
|
1093 |
\o
|
|
1094 |
\row
|
|
1095 |
\o Swedish
|
|
1096 |
\o 1
|
|
1097 |
\o 0, 2-100, 101-
|
|
1098 |
\o
|
|
1099 |
\o
|
|
1100 |
\row
|
|
1101 |
\o Tagalog
|
|
1102 |
\o 0, 1
|
|
1103 |
\o 2, 3, 5, 7-8, 10-13, 15, 17-18, 20-23...101...1001
|
|
1104 |
\o 4, 6, 9, 14, 16, 19, 24, 26, 29...104, 106, 109...
|
|
1105 |
\o
|
|
1106 |
\row
|
|
1107 |
\o Thai
|
|
1108 |
\o 0-
|
|
1109 |
\o
|
|
1110 |
\o
|
|
1111 |
\o
|
|
1112 |
\row
|
|
1113 |
\o Turkish
|
|
1114 |
\o 0-
|
|
1115 |
\o
|
|
1116 |
\o
|
|
1117 |
\o
|
|
1118 |
\row
|
|
1119 |
\o Ukrainian
|
|
1120 |
\o 1, 21, 31, 41, 51, 61, 71, 81, 91, 101...
|
|
1121 |
\o 2-4, 22-24, 32-34...
|
|
1122 |
\o 0, 5-20, 25-30, 35-40...
|
|
1123 |
\o
|
|
1124 |
\row
|
|
1125 |
\o Urdu
|
|
1126 |
\o 1
|
|
1127 |
\o 0, 2-100, 101-
|
|
1128 |
\o
|
|
1129 |
\o
|
|
1130 |
\row
|
|
1131 |
\o Vietnamese
|
|
1132 |
\o 0-
|
|
1133 |
\o
|
|
1134 |
\o
|
|
1135 |
\o
|
|
1136 |
\endtable
|
|
1137 |
|
|
1138 |
These rules are embedded within the Qt libraries, there is no need for
|
|
1139 |
the developer to know them. Merely to use the correct \c tr() call.
|
|
1140 |
|
|
1141 |
|
|
1142 |
\section2 Reusing Translations
|
|
1143 |
|
|
1144 |
If the translated text is similar to the source text, choose the
|
|
1145 |
\e {Copy from source text} entry in the \menu Translation menu (press
|
|
1146 |
\key{Ctrl+B}) which will copy the source text into the
|
|
1147 |
\l{The Translation Area} {translation area}.
|
|
1148 |
|
|
1149 |
\QL automatically lists possible translations from any open
|
|
1150 |
\l{Phrase Books} {phrase books} in the \l{Phrases and Guesses
|
|
1151 |
Window}, as well as similar or identical phrases that have already
|
|
1152 |
been translated.
|
|
1153 |
|
|
1154 |
\section2 Changing the Target Locale
|
|
1155 |
|
|
1156 |
\QL displays the target language in the \l{The Translation Area}
|
|
1157 |
{translation area}, and adapts the number of input fields for
|
|
1158 |
plural forms accordingly. If not explicitly set, \QL guesses the
|
|
1159 |
target language and country by evaluating the translation source
|
|
1160 |
file name: E.g. \c app_de.ts sets the target language to German,
|
|
1161 |
and \c app_de_ch.ts sets the target language to German and the
|
|
1162 |
target country to Switzerland (this also helps loading
|
|
1163 |
translations for the current locale automatically; see
|
|
1164 |
\l{linguist-programmers.html}{Programmers Manual} for details).
|
|
1165 |
If your files do not follow this convention, you can also set the
|
|
1166 |
locale information explicitly using \e {Translation File Settings}
|
|
1167 |
in the \menu Edit menu.
|
|
1168 |
|
|
1169 |
\image linguist-translationfilesettings.png
|
|
1170 |
|
|
1171 |
\section1 Phrase Books
|
|
1172 |
|
|
1173 |
A \QL phrase book is a set of source phrases, target
|
|
1174 |
(translated) phrases, and optional definitions. Typically one phrase book
|
|
1175 |
will be created per language and family of applications. Phrase books
|
|
1176 |
are used to provide a common set of translations to help ensure consistency.
|
|
1177 |
They can also be used to avoid duplication of effort since the translations
|
|
1178 |
for a family of applications can be produced once in the phrase book.
|
|
1179 |
If the translator reaches an untranslated phrase that is the same as a
|
|
1180 |
source phrase in a phrase book, \QL will show the
|
|
1181 |
phrase book entry in the \l {Phrases and Guesses Window}.
|
|
1182 |
|
|
1183 |
\section2 Creating and Editing Phrase Books
|
|
1184 |
|
|
1185 |
\image linguist-phrasebookdialog.png
|
|
1186 |
|
|
1187 |
Before a phrase book can be edited it must be created or, if it already
|
|
1188 |
exists, opened. Create a new phrase book by selecting
|
|
1189 |
\menu{Phrase|New Phrase Book} from the menu bar. You must enter a
|
|
1190 |
filename and may change the location of the file if you wish. A newly
|
|
1191 |
created phrase book is automatically opened. Open an existing phrase
|
|
1192 |
book by choosing \menu{Phrase|Open Phrase Book} from the menu bar.
|
|
1193 |
|
|
1194 |
The phrase book contents can be displayed and changed by selecting
|
|
1195 |
\menu{Phrase|Edit Phrase Book}, and then activating the phrase book you
|
|
1196 |
want to work on. This will pop up the Phrase Book Dialog as shown
|
|
1197 |
in the image above. To add a new phrase click the \gui{New Phrase}
|
|
1198 |
button (or press Alt+N) and type in a new source phrase. Press Tab and
|
|
1199 |
type in the translation. Optionally press Tab and enter a definition --
|
|
1200 |
this is useful to distinguish different translations of the same source
|
|
1201 |
phrase. This process may be repeated as often as necessary. You can delete
|
|
1202 |
a phrase by selecting it in the phrases list and clicking
|
|
1203 |
Remove Phrase. Click the \gui Close button (press Esc) once you've finished
|
|
1204 |
adding (and removing) phrases.
|
|
1205 |
|
|
1206 |
\section2 Shortcuts for Editing Phrase Books
|
|
1207 |
|
|
1208 |
You can also create a new phrase book entry directly out of the translation you
|
|
1209 |
are working on: Clicking \menu{Phrases|Add to Phrase Book} or pressing
|
|
1210 |
\key{Ctrl+T} will add the source text and the content of the first translation
|
|
1211 |
field to the current phrase book. If multiple phrase books are loaded,
|
|
1212 |
you have to specify the phrase book to add the entry to in a dialogue.
|
|
1213 |
If you detect an error in a phrase book entry that is shown in the
|
|
1214 |
\l{Phrases and Guesses Window}, you can also edit it in place by right
|
|
1215 |
clicking on the entry, and selecting \menu{Edit}. After fixing the error
|
|
1216 |
press \key{Return} to leave the editing mode.
|
|
1217 |
|
|
1218 |
\section2 Batch Translation
|
|
1219 |
|
|
1220 |
\image linguist-batchtranslation.png
|
|
1221 |
|
|
1222 |
Use the batch translation feature of \QL to automatically
|
|
1223 |
translate source texts that are also in a phrase book. Selecting
|
|
1224 |
\menu{Tools|Batch Translation} will show you the batch translation dialog,
|
|
1225 |
which let you configure which phrase books to use in what order during the
|
|
1226 |
batch translation process. Furthermore you can set whether only entries
|
|
1227 |
with no present translation should be considered, and whether batch translated
|
|
1228 |
entries should be set to finished (see also \l {String Translation States}).
|
|
1229 |
|
|
1230 |
\section1 Validation Tests
|
|
1231 |
|
|
1232 |
\QL provides four kinds of validation tests for translations.
|
|
1233 |
|
|
1234 |
\list 1
|
|
1235 |
\o \e {Accelerator validation} detects translated phrases
|
|
1236 |
that do not have an ampersand when the source phrase does and vice
|
|
1237 |
versa.
|
|
1238 |
\o \e {Punctuation validation} detects differences in the
|
|
1239 |
terminating punctuation between source and translated phrases when this
|
|
1240 |
may be significant, e.g. warns if the source phrase ends with an
|
|
1241 |
ellipsis, exclamation mark or question mark, and the translated phrase
|
|
1242 |
doesn't and vice versa.
|
|
1243 |
\o \e {Phrases validation} detects source phrases that are
|
|
1244 |
also in the phrase book but whose translation differs from that given in
|
|
1245 |
the phrase book.
|
|
1246 |
\o \e {Place marker validation} detects whether the same variables
|
|
1247 |
(like \c %1, \c %2) are used both in the source text and in the translation.
|
|
1248 |
\endlist
|
|
1249 |
|
|
1250 |
Validation may be switched on or off from the menu bar's
|
|
1251 |
Validation item or using the toolbar buttons. Unfinished phrases
|
|
1252 |
that fail validation are marked with an exclamation mark in the
|
|
1253 |
source text pane. Finished phrases will get a yellow tick
|
|
1254 |
instead. If you switch validation off and then switch it on later,
|
|
1255 |
\QL will recheck all phrases and mark any that fail
|
|
1256 |
validation. See also \l{String Translation States}.
|
|
1257 |
|
|
1258 |
\section1 Form Preview
|
|
1259 |
|
|
1260 |
\image linguist-previewtool.png
|
|
1261 |
|
|
1262 |
Forms created by \e{Qt Designer} are stored in special UI files.
|
|
1263 |
\QL can make use of these UI files to show the translations
|
|
1264 |
done so far on the form itself. This of course requires access to the UI
|
|
1265 |
files during the translation process. Activate
|
|
1266 |
\menu{Tools|Open/Refresh Form Preview} to open the window shown above.
|
|
1267 |
The list of UI files \QL has detected are displayed in the Forms
|
|
1268 |
List on the left hand. If the path to the files has changed, you can load
|
|
1269 |
the files manually via \menu{File|Open Form...}. Double-click on an entry
|
|
1270 |
in the Forms List to display the Form File. Select \e{<No Translation>} from
|
|
1271 |
the toolbar to display the untranslated form.
|
|
1272 |
|
|
1273 |
\section1 Qt Linguist Reference
|
|
1274 |
|
|
1275 |
|
|
1276 |
\section2 File Types
|
|
1277 |
|
|
1278 |
\QL makes use of four kinds of files:
|
|
1279 |
|
|
1280 |
\list
|
|
1281 |
\o TS \e {translation source files} \BR are human-readable XML
|
|
1282 |
files containing source phrases and their translations. These files are
|
|
1283 |
usually created and updated by \l lupdate and are specific to an
|
|
1284 |
application.
|
|
1285 |
\o \c .xlf \e {XLIFF files} \BR are human-readable XML files that adhere
|
|
1286 |
to the international XML Localization Interchange File Format. \QL
|
|
1287 |
can be used to edit XLIFF files generated by other programs. For standard
|
|
1288 |
Qt projects, however, only the TS file format is used.
|
|
1289 |
\o QM \e {Qt message files} \BR are binary files that contain
|
|
1290 |
translations used by an application at runtime. These files are
|
|
1291 |
generated by \l lrelease, but can also be generated by \QL.
|
|
1292 |
\o \c .qph \e {Qt phrase book files} \BR are human-readable XML
|
|
1293 |
files containing standard phrases and their translations. These files
|
|
1294 |
are created and updated by \QL and may be used by any
|
|
1295 |
number of projects and applications.
|
|
1296 |
\endlist
|
|
1297 |
|
|
1298 |
\target menubar
|
|
1299 |
\section2 The Menu Bar
|
|
1300 |
|
|
1301 |
\image linguist-menubar.png
|
|
1302 |
|
|
1303 |
\list
|
|
1304 |
\o \gui {File}
|
|
1305 |
\list
|
|
1306 |
\o \gui {Open... Ctrl+O} \BR pops up an open file dialog from which a
|
|
1307 |
translation source \c .ts or \c .xlf file can be chosen.
|
|
1308 |
\o \gui {Recently opened files} \BR shows the TS files that
|
|
1309 |
have been opened recently, click one to open it.
|
|
1310 |
\o \gui {Save Ctrl+S} \BR saves the current translation source file.
|
|
1311 |
\o \gui {Save As...} \BR pops up a save as file dialog so that the
|
|
1312 |
current translation source file may be saved with a different
|
|
1313 |
name, format and/or put in a different location.
|
|
1314 |
\o \gui {Release} \BR create a Qt message QM file with the same base
|
|
1315 |
name as the current translation source file. The release manager's
|
|
1316 |
command line tool \l lrelease performs the same function on
|
|
1317 |
\e all of an application's translation source files.
|
|
1318 |
\o \gui {Release As...} \BR pops up a save as file dialog. The
|
|
1319 |
filename entered will be a Qt message QM file of the translation
|
|
1320 |
based on the current translation source file. The release manager's
|
|
1321 |
command line tool \l lrelease performs the same function on
|
|
1322 |
\e all of an application's translation source files.
|
|
1323 |
\o \gui {Print... Ctrl+P} \BR pops up a print dialog. If you click
|
|
1324 |
OK the translation source and the translations will be printed.
|
|
1325 |
\o \gui {Exit Ctrl+Q} \BR closes \QL.
|
|
1326 |
\endlist
|
|
1327 |
|
|
1328 |
\o \gui {Edit}
|
|
1329 |
\list
|
|
1330 |
\o \gui {Undo Ctrl+Z} \BR undoes the last editing action in the
|
|
1331 |
translation pane.
|
|
1332 |
\o \gui {Redo Ctrl+Y} \BR redoes the last editing action in the
|
|
1333 |
translation pane.
|
|
1334 |
\o \gui {Cut Ctrl+X} \BR deletes any highlighted text in the
|
|
1335 |
translation pane and saves a copy to the clipboard.
|
|
1336 |
\o \gui {Copy Ctrl+C} \BR copies the highlighted text in the
|
|
1337 |
translation pane to the clipboard.
|
|
1338 |
\o \gui {Paste Ctrl+V} \BR pastes the clipboard text into the
|
|
1339 |
translation pane.
|
|
1340 |
\omit
|
|
1341 |
\o \gui {Delete} \BR deletes the highlighted text in the
|
|
1342 |
translation pane.
|
|
1343 |
\endomit
|
|
1344 |
\o \gui {Select All Ctrl+A} \BR selects all the text in the
|
|
1345 |
translation pane ready for copying or deleting.
|
|
1346 |
\o \gui {Find... Ctrl+F} \BR pops up the
|
|
1347 |
Find dialog. When the dialog pops up
|
|
1348 |
enter the text to be found and click the \gui {Find Next} button.
|
|
1349 |
Source phrases, translations and comments may be searched.
|
|
1350 |
\o \gui {Find Next F3} \BR finds the next occurrence of the text that
|
|
1351 |
was last entered in the Find dialog.
|
|
1352 |
\o \gui {Search and Translate...} \BR pops up the Search and
|
|
1353 |
Replace Dialog. Use this dialog to translate the same text in multiple items.
|
|
1354 |
\o \gui {Translation File Settings...} \BR let you configure the target
|
|
1355 |
language and the country/region of a translation source file.
|
|
1356 |
\endlist
|
|
1357 |
|
|
1358 |
\o \gui {Translation}
|
|
1359 |
\list
|
|
1360 |
\o \gui {Prev Unfinished Ctrl+K} \BR moves to the nearest previous
|
|
1361 |
unfinished source phrase (unfinished means untranslated or
|
|
1362 |
translated but failed validation).
|
|
1363 |
\o \gui {Next Unfinished Ctrl+L} \BR moves to the next unfinished source
|
|
1364 |
phrase.
|
|
1365 |
\o \gui {Prev Shift+Ctrl+K} \BR moves to the previous source phrase.
|
|
1366 |
\o \gui {Next Shift+Ctrl+L} \BR moves to the next source phrase.
|
|
1367 |
\o \gui {Done \& Next Ctrl+Enter} \BR mark this phrase as 'done'
|
|
1368 |
(translated) and move to the next unfinished source phrase.
|
|
1369 |
\o \gui {Copy from source text Ctrl+B} \BR copies the source text into
|
|
1370 |
the translation.
|
|
1371 |
\endlist
|
|
1372 |
|
|
1373 |
\o \gui {Validation} (See \l{Validation Tests})
|
|
1374 |
\list
|
|
1375 |
\o \gui {Accelerators} \BR toggles validation on or off for Alt
|
|
1376 |
accelerators.
|
|
1377 |
\o \gui {Ending Punctuation} \BR switches validation on or off
|
|
1378 |
for phrase ending punctuation, e.g. ellipsis, exclamation mark,
|
|
1379 |
question mark, etc.
|
|
1380 |
\o \gui {Phrase Matches} \BR sets validation on or off for
|
|
1381 |
matching against translations that are in the current phrase book.
|
|
1382 |
\o \gui {Place Marker Matches} \BR sets validation on or off for
|
|
1383 |
the use of the same place markers in the source and translation.
|
|
1384 |
\endlist
|
|
1385 |
|
|
1386 |
\o \gui {Phrases} (See the section \l {Phrase Books} for details.)
|
|
1387 |
\list
|
|
1388 |
|
|
1389 |
\o \gui {New Phrase Book... Ctrl+N} \BR pops up a save as file
|
|
1390 |
dialog. You must enter a filename to be used for the phrase
|
|
1391 |
book and save the file. Once saved you should open the phrase
|
|
1392 |
book to begin using it.
|
|
1393 |
|
|
1394 |
\o \gui {Open Phrase Book... Ctrl+H} \BR pops up an open file
|
|
1395 |
dialog. Find and choose a phrase book to open.
|
|
1396 |
|
|
1397 |
\o \gui {Close Phrase Book} \BR displays the list of phrase
|
|
1398 |
books currently opened. Clicking on one of the items will
|
|
1399 |
close the phrase book. If the phrase book has been modified, a
|
|
1400 |
dialog box asks whether \QL should save the changes.
|
|
1401 |
|
|
1402 |
\o \gui {Edit Phrase Book...} \BR displays the list of phrase
|
|
1403 |
books currently opened. Clicking on one of the items will open
|
|
1404 |
the \l{Creating and Editing Phrase Books}{Phrase Book Dialog}
|
|
1405 |
where you can add, edit or delete phrases.
|
|
1406 |
|
|
1407 |
\o \gui {Print Phrase Book...} \BR displays the list of phrase
|
|
1408 |
books currently opened. Clicking on one of the items pops up a
|
|
1409 |
print dialog. If you click OK the phrase book will be
|
|
1410 |
printed.
|
|
1411 |
|
|
1412 |
\o \gui {Add to Phrase Book Ctrl+T} \BR Adds the source text
|
|
1413 |
and translation currently shown in the \l{The Translation
|
|
1414 |
Area} {translation area} to a phrase book. If multiple phrase
|
|
1415 |
books are loaded, a dialog box let you specify select one.
|
|
1416 |
|
|
1417 |
\endlist
|
|
1418 |
|
|
1419 |
\o \gui {Tools}
|
|
1420 |
\list
|
|
1421 |
|
|
1422 |
\o \gui {Batch Translation...} \BR Opens a \l{Batch
|
|
1423 |
Translation}{dialog} which let you automatically insert
|
|
1424 |
translations for source texts which are in a phrase book.
|
|
1425 |
|
|
1426 |
\o \gui {Open/Refresh Form Preview F3} \BR Opens the \l{Form
|
|
1427 |
Preview}. This window let you instantly see translations for
|
|
1428 |
forms created with \QD. \endlist
|
|
1429 |
|
|
1430 |
\o \gui {View}
|
|
1431 |
\list
|
|
1432 |
|
|
1433 |
\o \gui {Revert Sorting} \BR puts the items in the \l{Context
|
|
1434 |
Window} {context list} and in the \l{Strings Window} {string
|
|
1435 |
list} into their original order.
|
|
1436 |
|
|
1437 |
\o \gui {Display Guesses} \BR turns the display of phrases and
|
|
1438 |
guesses on or off.
|
|
1439 |
|
|
1440 |
\o \gui {Statistics} \BR toggles the visibility of the
|
|
1441 |
Statistics dialog.
|
|
1442 |
|
|
1443 |
\o \gui {Views} \BR toggles the visibility of the \l{Context
|
|
1444 |
Window}, \l{Strings Window}, \l{Phrases and Guesses Window},
|
|
1445 |
\l{Warnings Window}, or \l{Sources and Forms Window}.
|
|
1446 |
|
|
1447 |
\o \gui {Toolbars} \BR toggles the visibility of the different
|
|
1448 |
toolbars.
|
|
1449 |
|
|
1450 |
\endlist
|
|
1451 |
|
|
1452 |
\o \gui {Help}
|
|
1453 |
\list
|
|
1454 |
\o \gui {Manual F1} \BR opens this manual.
|
|
1455 |
\o \gui {About Qt Linguist} \BR Shows information about \QL.
|
|
1456 |
\o \gui {About Qt} \BR Shows information about \e{Qt}.
|
|
1457 |
\o \gui {What's This? Shift+F1} \BR Click on one item in the main window
|
|
1458 |
to get additional information about it.
|
|
1459 |
\endlist
|
|
1460 |
|
|
1461 |
\endlist
|
|
1462 |
|
|
1463 |
\section2 The Toolbar
|
|
1464 |
|
|
1465 |
\image linguist-toolbar.png
|
|
1466 |
|
|
1467 |
\list
|
|
1468 |
\o \inlineimage linguist-fileopen.png
|
|
1469 |
\BR
|
|
1470 |
Pops up the open file dialog to open a new translation source TS file.
|
|
1471 |
|
|
1472 |
\o \inlineimage linguist-filesave.png
|
|
1473 |
\BR
|
|
1474 |
Saves the current translation source TS file.
|
|
1475 |
|
|
1476 |
\o \inlineimage linguist-fileprint.png
|
|
1477 |
\BR
|
|
1478 |
Prints the current translation source TS file.
|
|
1479 |
|
|
1480 |
\o \inlineimage linguist-phrasebookopen.png
|
|
1481 |
\BR
|
|
1482 |
Pops up the file open dialog to open a new phrase book \c .qph file.
|
|
1483 |
|
|
1484 |
\o \inlineimage linguist-editundo.png
|
|
1485 |
\BR
|
|
1486 |
Undoes the last editing action in the translation pane.
|
|
1487 |
|
|
1488 |
\o \inlineimage linguist-editredo.png
|
|
1489 |
\BR
|
|
1490 |
Redoes the last editing action in the translation pane.
|
|
1491 |
|
|
1492 |
\o \inlineimage linguist-editcut.png
|
|
1493 |
\BR
|
|
1494 |
Deletes any highlighted text in the translation pane and save a copy to
|
|
1495 |
the clipboard.
|
|
1496 |
|
|
1497 |
\o \inlineimage linguist-editcopy.png
|
|
1498 |
\BR
|
|
1499 |
Copies the highlighted text in the translation pane to the clipboard.
|
|
1500 |
|
|
1501 |
\o \inlineimage linguist-editpaste.png
|
|
1502 |
\BR
|
|
1503 |
Pastes the clipboard text into the translation pane.
|
|
1504 |
|
|
1505 |
\o \inlineimage linguist-editfind.png
|
|
1506 |
\BR
|
|
1507 |
Pops up the Find dialog .
|
|
1508 |
|
|
1509 |
\o \inlineimage linguist-prev.png
|
|
1510 |
\BR
|
|
1511 |
Moves to the previous source phrase.
|
|
1512 |
|
|
1513 |
\o \inlineimage linguist-next.png
|
|
1514 |
\BR
|
|
1515 |
Moves to the next source phrase.
|
|
1516 |
|
|
1517 |
\o \inlineimage linguist-prevunfinished.png
|
|
1518 |
\BR
|
|
1519 |
Moves to the previous unfinished source phrase.
|
|
1520 |
|
|
1521 |
\o \inlineimage linguist-nextunfinished.png
|
|
1522 |
\BR
|
|
1523 |
Moves to the next unfinished source phrase.
|
|
1524 |
|
|
1525 |
\o \inlineimage linguist-doneandnext.png
|
|
1526 |
\BR
|
|
1527 |
Marks the phrase as 'done' (translated) and move to the next
|
|
1528 |
unfinished source phrase.
|
|
1529 |
|
|
1530 |
\o \inlineimage linguist-validateaccelerators.png
|
|
1531 |
\BR
|
|
1532 |
Toggles accelerator validation on and off.
|
|
1533 |
|
|
1534 |
\o \inlineimage linguist-validatepunctuation.png
|
|
1535 |
\BR
|
|
1536 |
Toggles phrase ending punctuation validation on and off.
|
|
1537 |
|
|
1538 |
\o \inlineimage linguist-validatephrases.png
|
|
1539 |
\BR
|
|
1540 |
Toggles phrase book validation on or off.
|
|
1541 |
|
|
1542 |
\o \inlineimage linguist-validateplacemarkers.png
|
|
1543 |
\BR
|
|
1544 |
Toggles place marker validation on or off.
|
|
1545 |
|
|
1546 |
\endlist
|
|
1547 |
|
|
1548 |
*/
|
|
1549 |
|
|
1550 |
/*!
|
|
1551 |
\page linguist-programmers.html
|
|
1552 |
\title Qt Linguist Manual: Programmers
|
|
1553 |
|
|
1554 |
\contentspage {Qt Linguist Manual}{Contents}
|
|
1555 |
\previouspage Qt Linguist Manual: Translators
|
|
1556 |
\nextpage Qt Linguist Manual: TS File Format
|
|
1557 |
|
|
1558 |
Support for multiple languages is extremely simple in Qt
|
|
1559 |
applications, and adds little overhead to the programmer's workload.
|
|
1560 |
|
|
1561 |
Qt minimizes the performance cost of using translations by
|
|
1562 |
translating the phrases for each window as they are created. In most
|
|
1563 |
applications the main window is created just once. Dialogs are often
|
|
1564 |
created once and then shown and hidden as required. Once the initial
|
|
1565 |
translation has taken place there is no further runtime overhead for
|
|
1566 |
the translated windows. Only those windows that are created,
|
|
1567 |
destroyed and subsequently created will have a translation
|
|
1568 |
performance cost.
|
|
1569 |
|
|
1570 |
Creating applications that can switch language at runtime is possible
|
|
1571 |
with Qt, but requires a certain amount of programmer intervention and
|
|
1572 |
will of course incur some runtime performance cost.
|
|
1573 |
|
|
1574 |
\section1 Making the Application Translation-Aware
|
|
1575 |
|
|
1576 |
Programmers should make their application look for and load the
|
|
1577 |
appropriate translation file and mark user-visible text and Ctrl
|
|
1578 |
keyboard accelerators as targets for translation.
|
|
1579 |
|
|
1580 |
Each piece of text that requires translating requires context to help
|
|
1581 |
the translator identify where in the program the text occurs. In the
|
|
1582 |
case of multiple identical texts that require different translations,
|
|
1583 |
the translator also requires some information to disambiguate the
|
|
1584 |
source texts. Marking text for translation will automatically cause
|
|
1585 |
the class name to be used as basic context information. In some cases
|
|
1586 |
the programmer may be required to add additional information to help
|
|
1587 |
the translator.
|
|
1588 |
|
|
1589 |
\section2 Creating Translation Files
|
|
1590 |
|
|
1591 |
Translation files consist of all the user-visible text and Ctrl key
|
|
1592 |
accelerators in an application and translations of that text.
|
|
1593 |
Translation files are created as follows:
|
|
1594 |
|
|
1595 |
\list 1
|
|
1596 |
\o Run \l lupdate initially to generate the first set of TS
|
|
1597 |
translation source files with all the user-visible text but no
|
|
1598 |
translations.
|
|
1599 |
\o The TS files are given to the translator who adds translations
|
|
1600 |
using \QL. \QL takes care of any changed
|
|
1601 |
or deleted source text.
|
|
1602 |
\o Run \l lupdate to incorporate any new text added to the
|
|
1603 |
application. \l lupdate synchronizes the user-visible text from the
|
|
1604 |
application with the translations; it does not destroy any data.
|
|
1605 |
\o Steps 2 and 3 are repeated as often as necessary.
|
|
1606 |
\o When a release of the application is needed \l lrelease is run to
|
|
1607 |
read the TS files and produce the QM files used by the
|
|
1608 |
application at runtime.
|
|
1609 |
\endlist
|
|
1610 |
|
|
1611 |
For \l lupdate to work successfully, it must know which translation
|
|
1612 |
files to produce. The files are simply listed in the application's \c
|
|
1613 |
.pro Qt project file, for example:
|
|
1614 |
|
|
1615 |
\snippet examples/linguist/arrowpad/arrowpad.pro 1
|
|
1616 |
|
|
1617 |
If your sources contain genuine non-Latin1 strings, \l lupdate needs
|
|
1618 |
to be told about it in the \c .pro file by using, for example,
|
|
1619 |
the following line:
|
|
1620 |
|
|
1621 |
\code
|
|
1622 |
CODECFORTR = UTF-8
|
|
1623 |
\endcode
|
|
1624 |
|
|
1625 |
See the \l lupdate and \l lrelease sections.
|
|
1626 |
|
|
1627 |
\section2 Loading Translations
|
|
1628 |
|
|
1629 |
\snippet examples/linguist/hellotr/main.cpp 1
|
|
1630 |
\snippet examples/linguist/hellotr/main.cpp 3
|
|
1631 |
|
|
1632 |
This is how a simple \c main() function of a Qt application begins.
|
|
1633 |
|
|
1634 |
\snippet examples/linguist/hellotr/main.cpp 1
|
|
1635 |
\snippet examples/linguist/hellotr/main.cpp 4
|
|
1636 |
|
|
1637 |
For a translation-aware application a translator object is created, a
|
|
1638 |
translation is loaded and the translator object installed into the
|
|
1639 |
application.
|
|
1640 |
|
|
1641 |
\snippet examples/linguist/arrowpad/main.cpp 0
|
|
1642 |
\snippet examples/linguist/arrowpad/main.cpp 1
|
|
1643 |
|
|
1644 |
For non-Latin1 strings in the sources you will also need for example:
|
|
1645 |
|
|
1646 |
\code
|
|
1647 |
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
|
|
1648 |
\endcode
|
|
1649 |
|
|
1650 |
In production applications a more flexible approach, for example,
|
|
1651 |
loading translations according to locale, might be more appropriate. If
|
|
1652 |
the TS files are all named according to a convention such as
|
|
1653 |
\e appname_locale, e.g. \c tt2_fr, \c tt2_de etc, then the
|
|
1654 |
code above will load the current locale's translation at runtime.
|
|
1655 |
|
|
1656 |
If there is no translation file for the current locale the application
|
|
1657 |
will fall back to using the original source text.
|
|
1658 |
|
|
1659 |
Note that if you need to programmatically add translations at
|
|
1660 |
runtime, you can reimplement QTranslator::translate().
|
|
1661 |
|
|
1662 |
\section2 Making the Application Translate User-Visible Strings
|
|
1663 |
|
|
1664 |
User-visible strings are marked as translation targets by wrapping them
|
|
1665 |
in a \c tr() call, for example:
|
|
1666 |
|
|
1667 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 6
|
|
1668 |
|
|
1669 |
would become
|
|
1670 |
|
|
1671 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 7
|
|
1672 |
|
|
1673 |
All QObject subclasses that use the \c Q_OBJECT macro implement
|
|
1674 |
the \c tr() function.
|
|
1675 |
|
|
1676 |
Although the \c tr() call is normally made directly since it is
|
|
1677 |
usually called as a member function of a QObject subclass, in
|
|
1678 |
other cases an explicit class name can be supplied, for example:
|
|
1679 |
|
|
1680 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 8
|
|
1681 |
|
|
1682 |
or
|
|
1683 |
|
|
1684 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 9
|
|
1685 |
|
|
1686 |
\section2 Distinguishing Identical Strings That Require Different Translations
|
|
1687 |
|
|
1688 |
The \l lupdate program automatically provides a \e context for every
|
|
1689 |
source text. This context is the class name of the class that contains
|
|
1690 |
the \c tr() call. This is sufficient in the vast majority of cases.
|
|
1691 |
Sometimes however, the translator will need further information to
|
|
1692 |
uniquely identify a source text; for example, a dialog that contained
|
|
1693 |
two separate frames, each of which contained an "Enabled" option would
|
|
1694 |
need each identified because in some languages the translation would
|
|
1695 |
differ between the two. This is easily achieved using the
|
|
1696 |
two argument form of the \c tr() call, e.g.
|
|
1697 |
|
|
1698 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 10
|
|
1699 |
|
|
1700 |
and
|
|
1701 |
|
|
1702 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 11
|
|
1703 |
|
|
1704 |
Ctrl key accelerators are also translatable:
|
|
1705 |
|
|
1706 |
\snippet examples/linguist/trollprint/mainwindow.cpp 2
|
|
1707 |
|
|
1708 |
It is strongly recommended that the two argument form of \c tr() is used
|
|
1709 |
for Ctrl key accelerators. The second argument is the only clue the
|
|
1710 |
translator has as to the function performed by the accelerator.
|
|
1711 |
|
|
1712 |
\section2 Helping the Translator with Navigation Information
|
|
1713 |
|
|
1714 |
In large complex applications it may be difficult for the translator to
|
|
1715 |
see where a particular source text comes from. This problem can be
|
|
1716 |
solved by adding a comment using the keyword \e TRANSLATOR which
|
|
1717 |
describes the navigation steps to reach the text in question; e.g.
|
|
1718 |
|
|
1719 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 12
|
|
1720 |
|
|
1721 |
These comments are particularly useful for widget classes.
|
|
1722 |
|
|
1723 |
\section2 Handling Plural Forms
|
|
1724 |
|
|
1725 |
Qt includes a \c tr() overload that will make it very easy to
|
|
1726 |
write "plural-aware" internationalized applications. This overload
|
|
1727 |
has the following signature:
|
|
1728 |
|
|
1729 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 17
|
|
1730 |
|
|
1731 |
Depending on the value of \c n, the \c tr() function will return a different
|
|
1732 |
translation, with the correct grammatical number for the target language.
|
|
1733 |
Also, any occurrence of \c %n is replaced with \c{n}'s value. For example:
|
|
1734 |
|
|
1735 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 18
|
|
1736 |
|
|
1737 |
If a French translation is loaded, this will expand to "0 item
|
|
1738 |
remplac\unicode{233}", "1 item remplac\unicode{233}", "2 items
|
|
1739 |
remplac\unicode{233}s", etc., depending on \c{n}'s value.
|
|
1740 |
And if no translation is loaded, the orignal string is used, with \c %n
|
|
1741 |
replaced with count's value (e.g., "6 item(s) replaced").
|
|
1742 |
|
|
1743 |
To handle plural forms in the native language, you need to load a
|
|
1744 |
translation file for this language, too. \l lupdate has the
|
|
1745 |
\c -pluralonly command line option, which allows the creation of
|
|
1746 |
TS files containing only entries with plural forms.
|
|
1747 |
|
|
1748 |
See the \l{http://qt.nokia.com/doc/qq/}{Qt Quarterly} Article
|
|
1749 |
\l{http://qt.nokia.com/doc/qq/qq19-plurals.html}{Plural Forms in Translations}
|
|
1750 |
for further details on this issue.
|
|
1751 |
|
|
1752 |
\section2 Coping With C++ Namespaces
|
|
1753 |
|
|
1754 |
C++ namespaces and the \c {using namespace} statement can confuse
|
|
1755 |
\l lupdate. It will interpret \c MyClass::tr() as meaning just
|
|
1756 |
that, not as \c MyNamespace::MyClass::tr(), even if \c MyClass is
|
|
1757 |
defined in the \c MyNamespace namespace. Runtime translation of
|
|
1758 |
these strings will fail because of that.
|
|
1759 |
|
|
1760 |
You can work around this limitation by putting a \e TRANSLATOR
|
|
1761 |
comment at the beginning of the source files that use \c
|
|
1762 |
MyClass::tr():
|
|
1763 |
|
|
1764 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 13
|
|
1765 |
|
|
1766 |
After the comment, all references to \c MyClass::tr() will be
|
|
1767 |
understood as meaning \c MyNamespace::MyClass::tr().
|
|
1768 |
|
|
1769 |
\section2 Translating Text That is Outside of a QObject Subclass
|
|
1770 |
|
|
1771 |
\section3 Using QCoreApplication::translate()
|
|
1772 |
|
|
1773 |
If the quoted text is not in a member function of a QObject subclass,
|
|
1774 |
use either the tr() function of an appropriate class, or the
|
|
1775 |
QCoreApplication::translate() function directly:
|
|
1776 |
|
|
1777 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 14
|
|
1778 |
|
|
1779 |
\section3 Using QT_TR_NOOP() and QT_TRANSLATE_NOOP()
|
|
1780 |
|
|
1781 |
If you need to have translatable text completely outside a function,
|
|
1782 |
there are two macros to help: QT_TR_NOOP() and QT_TRANSLATE_NOOP().
|
|
1783 |
These macros merely mark the text for extraction by \l{lupdate}.
|
|
1784 |
The macros expand to just the text (without the context).
|
|
1785 |
|
|
1786 |
Example of QT_TR_NOOP():
|
|
1787 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 15
|
|
1788 |
|
|
1789 |
Example of QT_TRANSLATE_NOOP():
|
|
1790 |
\snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 16
|
|
1791 |
|
|
1792 |
\section1 Tutorials
|
|
1793 |
|
|
1794 |
Three tutorials are presented:
|
|
1795 |
|
|
1796 |
\list 1
|
|
1797 |
\o \l{linguist/hellotr}{Hello tr()} demonstrates the creation of
|
|
1798 |
a \l QTranslator object. It also shows the simplest use of
|
|
1799 |
the \c tr() function to mark user-visible source text for
|
|
1800 |
translation.
|
|
1801 |
|
|
1802 |
\o \l{linguist/arrowpad}{Arrow Pad} explains how to make the application load the
|
|
1803 |
translation file applicable to the current locale. It also shows the
|
|
1804 |
use of the two-argument form of \c tr() which provides additional
|
|
1805 |
information to the translator.
|
|
1806 |
|
|
1807 |
\o \l{linguist/trollprint}{Troll Print} explains how
|
|
1808 |
identical source texts can be distinguished even when they occur in
|
|
1809 |
the same context. This tutorial also discusses how the translation
|
|
1810 |
tools help minimize the translator's work when an application is
|
|
1811 |
upgraded.
|
|
1812 |
\endlist
|
|
1813 |
|
|
1814 |
These tutorials cover all that you need to know to prepare your Qt
|
|
1815 |
applications for translation.
|
|
1816 |
|
|
1817 |
At the beginning of a project add the translation source files to be
|
|
1818 |
used to the project file and add calls to \l lupdate and \l lrelease to
|
|
1819 |
the makefile.
|
|
1820 |
|
|
1821 |
During the project all the programmer must do is wrap any user-visible
|
|
1822 |
text in \c tr() calls. They should also use the two argument form for
|
|
1823 |
Ctrl key accelerators, or when asked by the translator for the cases
|
|
1824 |
where the same text translates into two different forms in the same
|
|
1825 |
context. The programmer should also include \c TRANSLATION comments to
|
|
1826 |
help the translator navigate the application.
|
|
1827 |
*/
|
|
1828 |
|
|
1829 |
/*!
|
|
1830 |
\page linguist-ts-file-format.html
|
|
1831 |
\title Qt Linguist Manual: TS File Format
|
|
1832 |
|
|
1833 |
\contentspage {Qt Linguist Manual}{Contents}
|
|
1834 |
\previouspage Qt Linguist Manual: Programmers
|
|
1835 |
|
|
1836 |
The TS file format used by \QL is described by the
|
|
1837 |
\l{http://www.w3.org/TR/1998/REC-xml-19980210}{DTD} presented below,
|
|
1838 |
which we include for your convenience. Be aware that the format
|
|
1839 |
may change in future Qt releases.
|
|
1840 |
|
|
1841 |
\quotefile tools/linguist/shared/ts.dtd
|
|
1842 |
|
|
1843 |
*/
|