File: gettext_4.html

package info (click to toggle)
poedit 1.0.3-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,040 kB
  • ctags: 897
  • sloc: cpp: 6,155; sh: 2,001; xml: 1,115; makefile: 120
file content (337 lines) | stat: -rw-r--r-- 11,338 bytes parent folder | download
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.54
     from gettext.texi on 25 January 1999 -->

<TITLE>GNU gettext utilities - Making the Initial PO File</TITLE>
<link href="gettext_5.html" rel=Next>
<link href="gettext_3.html" rel=Previous>
<link href="gettext_toc.html" rel=ToC>

</HEAD>
<BODY>
<p>Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_3.html">previous</A>, <A HREF="gettext_5.html">next</A>, <A HREF="gettext_12.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC19" HREF="gettext_toc.html#TOC19">Making the Initial PO File</A></H1>



<H2><A NAME="SEC20" HREF="gettext_toc.html#TOC20">Invoking the <CODE>xgettext</CODE> Program</A></H2>


<PRE>
xgettext [<VAR>option</VAR>] <VAR>inputfile</VAR> ...
</PRE>

<DL COMPACT>

<DT><SAMP>`-a'</SAMP>
<DD>
<DT><SAMP>`--extract-all'</SAMP>
<DD>
Extract all strings.

<DT><SAMP>`-c [<VAR>tag</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--add-comments[=<VAR>tag</VAR>]'</SAMP>
<DD>
Place comment block with <VAR>tag</VAR> (or those preceding keyword lines)
in output file.

<DT><SAMP>`-C'</SAMP>
<DD>
<DT><SAMP>`--c++'</SAMP>
<DD>
Recognize C++ style comments.

<DT><SAMP>`--debug'</SAMP>
<DD>
Use the flags <KBD>c-format</KBD> and <KBD>possible-c-format</KBD> to show who was
responsible for marking a message as a format string.  The later form is
used if the <CODE>xgettext</CODE> program decided, the format form is used if
the programmer prescribed it.

By default only the <KBD>c-format</KBD> form is used.  The translator should
not have to care about these details.

<DT><SAMP>`-d <VAR>name</VAR>'</SAMP>
<DD>
<DT><SAMP>`--default-domain=<VAR>name</VAR>'</SAMP>
<DD>
Use <TT>`<VAR>name</VAR>.po'</TT> for output (instead of <TT>`messages.po'</TT>).

The special domain name <TT>`-'</TT> or <TT>`/dev/stdout'</TT> means to write
the output to <TT>`stdout'</TT>.

<DT><SAMP>`-D <VAR>directory</VAR>'</SAMP>
<DD>
<DT><SAMP>`--directory=<VAR>directory</VAR>'</SAMP>
<DD>
Change to <VAR>directory</VAR> before beginning to search and scan source
files.  The resulting <TT>`.po'</TT> file will be written relative to the
original directory, though.

<DT><SAMP>`-f <VAR>file</VAR>'</SAMP>
<DD>
<DT><SAMP>`--files-from=<VAR>file</VAR>'</SAMP>
<DD>
Read the names of the input files from <VAR>file</VAR> instead of getting
them from the command line.

<DT><SAMP>`--force'</SAMP>
<DD>
Always write output file even if no message is defined.

<DT><SAMP>`-h'</SAMP>
<DD>
<DT><SAMP>`--help'</SAMP>
<DD>
Display this help and exit.

<DT><SAMP>`-I <VAR>list</VAR>'</SAMP>
<DD>
<DT><SAMP>`--input-path=<VAR>list</VAR>'</SAMP>
<DD>
List of directories searched for input files.

<DT><SAMP>`-j'</SAMP>
<DD>
<DT><SAMP>`--join-existing'</SAMP>
<DD>
Join messages with existing file.

<DT><SAMP>`-k <VAR>word</VAR>'</SAMP>
<DD>
<DT><SAMP>`--keyword[=<VAR>word</VAR>]'</SAMP>
<DD>
Additonal keyword to be looked for (without <VAR>word</VAR> means not to
use default keywords).

The default keywords, which are always looked for if not explicitly
disabled, are <CODE>gettext</CODE>, <CODE>dgettext</CODE>, <CODE>dcgettext</CODE> and
<CODE>gettext_noop</CODE>.

<DT><SAMP>`-m [<VAR>string</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--msgstr-prefix[=<VAR>string</VAR>]'</SAMP>
<DD>
Use <VAR>string</VAR> or "" as prefix for msgstr entries.

<DT><SAMP>`-M [<VAR>string</VAR>]'</SAMP>
<DD>
<DT><SAMP>`--msgstr-suffix[=<VAR>string</VAR>]'</SAMP>
<DD>
Use <VAR>string</VAR> or "" as suffix for msgstr entries.

<DT><SAMP>`--no-location'</SAMP>
<DD>
Do not write <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>'</SAMP> lines.

<DT><SAMP>`-n'</SAMP>
<DD>
<DT><SAMP>`--add-location'</SAMP>
<DD>
Generate <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>'</SAMP> lines (default).

<DT><SAMP>`--omit-header'</SAMP>
<DD>
Don't write header with <SAMP>`msgid ""'</SAMP> entry.

This is useful for testing purposes because it eliminates a source
of variance for generated <CODE>.gmo</CODE> files.  We can ship some of
these files in the GNU <CODE>gettext</CODE> package, and the result of
regenerating them through <CODE>msgfmt</CODE> should yield the same values.

<DT><SAMP>`-p <VAR>dir</VAR>'</SAMP>
<DD>
<DT><SAMP>`--output-dir=<VAR>dir</VAR>'</SAMP>
<DD>
Output files will be placed in directory <VAR>dir</VAR>.

<DT><SAMP>`-s'</SAMP>
<DD>
<DT><SAMP>`--sort-output'</SAMP>
<DD>
Generate sorted output and remove duplicates.

<DT><SAMP>`--strict'</SAMP>
<DD>
Write out strict Uniforum conforming PO file.

<DT><SAMP>`-v'</SAMP>
<DD>
<DT><SAMP>`--version'</SAMP>
<DD>
Output version information and exit.

<DT><SAMP>`-x <VAR>file</VAR>'</SAMP>
<DD>
<DT><SAMP>`--exclude-file=<VAR>file</VAR>'</SAMP>
<DD>
Entries from <VAR>file</VAR> are not extracted.

</DL>

<P>
Search path for supplementary PO files is:
<TT>`/usr/local/share/nls/src/'</TT>.

</P>
<P>
If <VAR>inputfile</VAR> is <SAMP>`-'</SAMP>, standard input is read.

</P>
<P>
This implementation of <CODE>xgettext</CODE> is able to process a few awkward
cases, like strings in preprocessor macros, ANSI concatenation of
adjacent strings, and escaped end of lines for continued strings.

</P>


<H2><A NAME="SEC21" HREF="gettext_toc.html#TOC21">C Sources Context</A></H2>

<P>
PO mode is particularily powerful when used with PO files
created through GNU <CODE>gettext</CODE> utilities, as those utilities
insert special comments in the PO files they generate.
Some of these special comments relate the PO file entry to
exactly where the untranslated string appears in the program sources.

</P>
<P>
When the translator gets to an untranslated entry, she is fairly
often faced with an original string which is not as informative as
it normally should be, being succinct, cryptic, or otherwise ambiguous.
Before chosing how to translate the string, she needs to understand
better what the string really means and how tight the translation has
to be.  Most of times, when problems arise, the only way left to make
her judgment is looking at the true program sources from where this
string originated, searching for surrounding comments the programmer
might have put in there, and looking around for helping clues of
<EM>any</EM> kind.

</P>
<P>
Surely, when looking at program sources, the translator will receive
more help if she is a fluent programmer.  However, even if she is
not versed in programming and feels a little lost in C code, the
translator should not be shy at taking a look, once in a while.
It is most probable that she will still be able to find some of the
hints she needs.  She will learn quickly to not feel uncomfortable
in program code, paying more attention to programmer's comments,
variable and function names (if he dared chosing them well), and
overall organization, than to programmation itself.

</P>
<P>
The following commands are meant to help the translator at getting
program source context for a PO file entry.

</P>
<DL COMPACT>

<DT><KBD>s</KBD>
<DD>
Resume the display of a program source context, or cycle through them.

<DT><KBD>M-s</KBD>
<DD>
Display of a program source context selected by menu.

<DT><KBD>S</KBD>
<DD>
Add a directory to the search path for source files.

<DT><KBD>M-S</KBD>
<DD>
Delete a directory from the search path for source files.

</DL>

<P>
The commands <KBD>s</KBD> (<CODE>po-cycle-reference</CODE>) and <KBD>M-s</KBD>
(<CODE>po-select-source-reference</CODE>) both open another window displaying
some source program file, and already positioned in such a way that
it shows an actual use of the string to be translated.  By doing
so, the command gives source program context for the string.  But if
the entry has no source context references, or if all references
are unresolved along the search path for program sources, then the
command diagnoses this as an error.

</P>
<P>
Even if <KBD>s</KBD> (or <KBD>M-s</KBD>) opens a new window, the cursor stays
in the PO file window.  If the translator really wants to
get into the program source window, she ought to do it explicitly,
maybe by using command <KBD>O</KBD>.

</P>
<P>
When <KBD>s</KBD> is typed for the first time, or for a PO file entry which
is different of the last one used for getting source context, then the
command reacts by giving the first context available for this entry,
if any.  If some context has already been recently displayed for the
current PO file entry, and the translator wandered off to do other
things, typing <KBD>s</KBD> again will merely resume, in another window,
the context last displayed.  In particular, if the translator moved
the cursor away from the context in the source file, the command will
bring the cursor back to the context.  By using <KBD>s</KBD> many times
in a row, with no other commands intervening, PO mode will cycle to
the next available contexts for this particular entry, getting back
to the first context once the last has been shown.

</P>
<P>
The command <KBD>M-s</KBD> behaves differently.  Instead of cycling through
references, it lets the translator choose of particular reference among
many, and displays that reference.  It is best used with completion,
if the translator types <KBD>TAB</KBD> immediately after <KBD>M-s</KBD>, in
response to the question, she will be offered a menu of all possible
references, as a reminder of which are the acceptable answers.
This command is useful only where there are really many contexts
available for a single string to translate.

</P>
<P>
Program source files are usually found relative to where the PO
file stands.  As a special provision, when this fails, the file is
also looked for, but relative to the directory immediately above it.
Those two cases take proper care of most PO files.  However, it might
happen that a PO file has been moved, or is edited in a different
place than its normal location.  When this happens, the translator
should tell PO mode in which directory normally sits the genuine PO
file.  Many such directories may be specified, and all together, they
constitute what is called the <STRONG>search path</STRONG> for program sources.
The command <KBD>S</KBD> (<CODE>po-consider-source-path</CODE>) is used to interactively
enter a new directory at the front of the search path, and the command
<KBD>M-S</KBD> (<CODE>po-ignore-source-path</CODE>) is used to select, with completion,
one of the directories she does not want anymore on the search path.

</P>


<H2><A NAME="SEC22" HREF="gettext_toc.html#TOC22">Using Translation Compendiums</A></H2>

<P>
Compendiums are yet to be implemented.

</P>
<P>
An incoming PO mode feature will let the translator maintain a
compendium of already achieved translations.  A <STRONG>compendium</STRONG>
is a special PO file containing a set of translations recurring in
many different packages.  The translator will be given commands for
adding entries to her compendium, and later initializing untranslated
entries, or updating already translated entries, from translations
kept in the compendium.  For this to work, however, the compendium
would have to be normalized.  See section <A HREF="gettext_2.html#SEC12">Normalizing Strings in Entries</A>.

</P>

<P><HR><P>
<p>Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_3.html">previous</A>, <A HREF="gettext_5.html">next</A>, <A HREF="gettext_12.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
</BODY>
</HTML>