summaryrefslogtreecommitdiffstats
path: root/tools/linguist/book/linguist-manager.leaf
blob: 9acf9263432777a64ff054b7d3777f0e434250ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
\chapter Release Manager

\index Release Manager

Two tools are provided for the release manager, \l lupdate and \l
lrelease. These tools depend on \e qmake project files. You don't
have to use \e qmake, though.

A third tool, \c tqm2ts, can be used for converting TQt 2.x message
files to \c .ts files.

\section1 TQt Project Files

\index .pro Files
\index Project Files
\index qmake!Project Files

\l lupdate and \l lrelease depend on information in the application's
\c .pro TQt project file. There must be an entry in the \c TRANSLATIONS
section of the project file for each language that is additional to
the native language. A typical entry looks like this:

\index TRANSLATIONS!in Project Files

\quotefile tt2/tt2.pro
\skipto TRANSLATIONS
\printline tt2_fr
\printline tt2_nl

Using a locale within the translation file name is useful for
determining which language to load at runtime. This is explained in
\link Programmers Chapter 4: Programmers \endlink.

\index HEADERS!in Project Files
\index SOURCES!in Project Files
\index FORMS!in Project Files
\index TRANSLATIONS!in Project Files

An example of a complete \c .pro file with four translation source files:
\code
    HEADERS         = main-dlg.h \
		      options-dlg.h
    SOURCES         = main-dlg.cpp \
		      options-dlg.cpp \
		      main.cpp 
    FORMS           = search-dlg.ui
    TRANSLATIONS    = superapp_dk.ts \
		      superapp_fi.ts \
		      superapp_no.ts \
		      superapp_se.ts
\endcode

\index QApplication!defaultCodec()
\index defaultCodec()!QApplication
\index DEFAULTCODEC!in Project Files
\index Chinese Language
\index Japanese Language

\l QTextCodec::setCodecForTr() makes it possible to choose a
8-bit encoding for literal strings that appear within \c tr() calls.
This is useful for applications whose source language is, for example,
Chinese or Japanese. If no encoding is set, \c tr() uses Latin-1.

If you do use the \l QTextCodec::codecForTr() mechanism in your
application, \e {Qt Linguist} needs you to set the \c DEFAULTCODEC
entry in the \c .pro file as well. For example:
\code
    DEFAULTCODEC    = ISO-8859-5
\endcode

\section1 lupdate

\index lupdate

Usage: \c {lupdate myproject.pro}

  \index TQt Designer

This is a simple command line tool. \l lupdate reads a TQt \c .pro
project file, finds the translatable strings in the specified source,
header and \e {Qt Designer} interface files, and produces or updates
the \c .ts translation files listed in the project file. The
translation files are given to the translator who uses \e {Qt
Linguist} to read the files and insert the translations.

Companies that have their own translators in-house may find it useful
to run \l lupdate regularly, perhaps monthly, as the application
develops. This will lead to a fairly low volume of translation work
spread evenly over the life of the project and will allow the
translators to support a number of projects simultaneously.

Companies that hire in translators as required may prefer to run \l
lupdate only a few times in the application's life cycle, the first
time might be just before the first test phase. This will provide the
translator with a substantial single block of work and any bugs that
the translator detects may easily be included with those found during
the initial test phase. The second and any subsequent \l lupdate runs
would probably take place during the final beta phase.

\index .ts Files
\index Translation Source Files
\index XML

The \c .ts file format is a simple human-readable XML format that can
be used with version control systems if required.

\section1 lrelease

\index lrelease

Usage: \c {lrelease myproject.pro}

\index .qm Files
\index TQt Message Files

This is another simple command line tool. It reads a TQt \c .pro
project file and produces the \c .qm files used by the application,
one for each \c .ts translation source file listed in the project
file. The \c .qm file format is a compact binary format that provides
extremely fast lookups for translations.

This tool is run whenever a release of the application is to be made,
from initial test version through to final release version. If the \c
.qm files are not created, e.g. because an alpha release is required
before any translation has been undertaken, the application will run
perfectly well using the text the programmers placed in the source
files. Once the \c .qm files are available the application will
detect them and use them automatically.

Note that \l lrelease will only incorporate translations that are
marked as "done". If a translation is missing, or has failed
validation, the original text will be used instead.

\section1 Missing Translations

Both \l lupdate and \l lrelease may be used with \c .ts translation
source files which are incomplete. Missing translations will be replaced
with the native language phrases at runtime.