Imported Upstream version 0.19.8.1
[platform/upstream/gettext.git] / gettext-tools / doc / gettext_5.html
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.52b
4      from gettext.texi on 11 June 2016 -->
5
6 <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
7 <TITLE>GNU gettext utilities - 5  Making the PO Template File</TITLE>
8 </HEAD>
9 <BODY>
10 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_4.html">previous</A>, <A HREF="gettext_6.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
11 <P><HR><P>
12
13
14 <H1><A NAME="SEC27" HREF="gettext_toc.html#TOC27">5  Making the PO Template File</A></H1>
15 <P>
16 <A NAME="IDX164"></A>
17
18 </P>
19 <P>
20 After preparing the sources, the programmer creates a PO template file.
21 This section explains how to use <CODE>xgettext</CODE> for this purpose.
22
23 </P>
24 <P>
25 <CODE>xgettext</CODE> creates a file named <TT>&lsquo;<VAR>domainname</VAR>.po&rsquo;</TT>.  You
26 should then rename it to <TT>&lsquo;<VAR>domainname</VAR>.pot&rsquo;</TT>.  (Why doesn't
27 <CODE>xgettext</CODE> create it under the name <TT>&lsquo;<VAR>domainname</VAR>.pot&rsquo;</TT>
28 right away?  The answer is: for historical reasons.  When <CODE>xgettext</CODE>
29 was specified, the distinction between a PO file and PO file template
30 was fuzzy, and the suffix <SAMP>&lsquo;.pot&rsquo;</SAMP> wasn't in use at that time.)
31
32 </P>
33
34
35
36 <H2><A NAME="SEC28" HREF="gettext_toc.html#TOC28">5.1  Invoking the <CODE>xgettext</CODE> Program</A></H2>
37
38 <P>
39 <A NAME="IDX165"></A>
40 <A NAME="IDX166"></A>
41
42 <PRE>
43 xgettext [<VAR>option</VAR>] [<VAR>inputfile</VAR>] ...
44 </PRE>
45
46 <P>
47 The <CODE>xgettext</CODE> program extracts translatable strings from given
48 input files.
49
50 </P>
51
52
53 <H3><A NAME="SEC29" HREF="gettext_toc.html#TOC29">5.1.1  Input file location</A></H3>
54
55 <DL COMPACT>
56
57 <DT><SAMP>&lsquo;<VAR>inputfile</VAR> ...&rsquo;</SAMP>
58 <DD>
59 Input files.
60
61 <DT><SAMP>&lsquo;-f <VAR>file</VAR>&rsquo;</SAMP>
62 <DD>
63 <DT><SAMP>&lsquo;--files-from=<VAR>file</VAR>&rsquo;</SAMP>
64 <DD>
65 <A NAME="IDX167"></A>
66 <A NAME="IDX168"></A>
67 Read the names of the input files from <VAR>file</VAR> instead of getting
68 them from the command line.
69
70 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
71 <DD>
72 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
73 <DD>
74 <A NAME="IDX169"></A>
75 <A NAME="IDX170"></A>
76 Add <VAR>directory</VAR> to the list of directories.  Source files are
77 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
78 file will be written relative to the current directory, though.
79
80 </DL>
81
82 <P>
83 If <VAR>inputfile</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
84
85 </P>
86
87
88 <H3><A NAME="SEC30" HREF="gettext_toc.html#TOC30">5.1.2  Output file location</A></H3>
89
90 <DL COMPACT>
91
92 <DT><SAMP>&lsquo;-d <VAR>name</VAR>&rsquo;</SAMP>
93 <DD>
94 <DT><SAMP>&lsquo;--default-domain=<VAR>name</VAR>&rsquo;</SAMP>
95 <DD>
96 <A NAME="IDX171"></A>
97 <A NAME="IDX172"></A>
98 Use <TT>&lsquo;<VAR>name</VAR>.po&rsquo;</TT> for output (instead of <TT>&lsquo;messages.po&rsquo;</TT>).
99
100 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
101 <DD>
102 <DT><SAMP>&lsquo;--output=<VAR>file</VAR>&rsquo;</SAMP>
103 <DD>
104 <A NAME="IDX173"></A>
105 <A NAME="IDX174"></A>
106 Write output to specified file (instead of <TT>&lsquo;<VAR>name</VAR>.po&rsquo;</TT> or
107 <TT>&lsquo;messages.po&rsquo;</TT>).
108
109 <DT><SAMP>&lsquo;-p <VAR>dir</VAR>&rsquo;</SAMP>
110 <DD>
111 <DT><SAMP>&lsquo;--output-dir=<VAR>dir</VAR>&rsquo;</SAMP>
112 <DD>
113 <A NAME="IDX175"></A>
114 <A NAME="IDX176"></A>
115 Output files will be placed in directory <VAR>dir</VAR>.
116
117 </DL>
118
119 <P>
120 <A NAME="IDX177"></A>
121 If the output <VAR>file</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP> or <SAMP>&lsquo;/dev/stdout&rsquo;</SAMP>, the output
122 is written to standard output.
123
124 </P>
125
126
127 <H3><A NAME="SEC31" HREF="gettext_toc.html#TOC31">5.1.3  Choice of input file language</A></H3>
128
129 <DL COMPACT>
130
131 <DT><SAMP>&lsquo;-L <VAR>name</VAR>&rsquo;</SAMP>
132 <DD>
133 <DT><SAMP>&lsquo;--language=<VAR>name</VAR>&rsquo;</SAMP>
134 <DD>
135 <A NAME="IDX178"></A>
136 <A NAME="IDX179"></A>
137 <A NAME="IDX180"></A>
138 Specifies the language of the input files.  The supported languages
139 are <CODE>C</CODE>, <CODE>C++</CODE>, <CODE>ObjectiveC</CODE>, <CODE>PO</CODE>, <CODE>Shell</CODE>,
140 <CODE>Python</CODE>, <CODE>Lisp</CODE>, <CODE>EmacsLisp</CODE>, <CODE>librep</CODE>, <CODE>Scheme</CODE>,
141 <CODE>Smalltalk</CODE>, <CODE>Java</CODE>, <CODE>JavaProperties</CODE>, <CODE>C#</CODE>, <CODE>awk</CODE>,
142 <CODE>YCP</CODE>, <CODE>Tcl</CODE>, <CODE>Perl</CODE>, <CODE>PHP</CODE>, <CODE>GCC-source</CODE>,
143 <CODE>NXStringTable</CODE>, <CODE>RST</CODE>, <CODE>Glade</CODE>, <CODE>Lua</CODE>, <CODE>JavaScript</CODE>,
144 <CODE>Vala</CODE>, <CODE>GSettings</CODE>, <CODE>Desktop</CODE>.
145
146 <DT><SAMP>&lsquo;-C&rsquo;</SAMP>
147 <DD>
148 <DT><SAMP>&lsquo;--c++&rsquo;</SAMP>
149 <DD>
150 <A NAME="IDX181"></A>
151 <A NAME="IDX182"></A>
152 This is a shorthand for <CODE>--language=C++</CODE>.
153
154 </DL>
155
156 <P>
157 By default the language is guessed depending on the input file name
158 extension.
159
160 </P>
161
162
163 <H3><A NAME="SEC32" HREF="gettext_toc.html#TOC32">5.1.4  Input file interpretation</A></H3>
164
165 <DL COMPACT>
166
167 <DT><SAMP>&lsquo;--from-code=<VAR>name</VAR>&rsquo;</SAMP>
168 <DD>
169 <A NAME="IDX183"></A>
170 Specifies the encoding of the input files.  This option is needed only
171 if some untranslated message strings or their corresponding comments
172 contain non-ASCII characters.  Note that Tcl and Glade input files are
173 always assumed to be in UTF-8, regardless of this option.
174
175 </DL>
176
177 <P>
178 By default the input files are assumed to be in ASCII.
179
180 </P>
181
182
183 <H3><A NAME="SEC33" HREF="gettext_toc.html#TOC33">5.1.5  Operation mode</A></H3>
184
185 <DL COMPACT>
186
187 <DT><SAMP>&lsquo;-j&rsquo;</SAMP>
188 <DD>
189 <DT><SAMP>&lsquo;--join-existing&rsquo;</SAMP>
190 <DD>
191 <A NAME="IDX184"></A>
192 <A NAME="IDX185"></A>
193 Join messages with existing file.
194
195 <DT><SAMP>&lsquo;-x <VAR>file</VAR>&rsquo;</SAMP>
196 <DD>
197 <DT><SAMP>&lsquo;--exclude-file=<VAR>file</VAR>&rsquo;</SAMP>
198 <DD>
199 <A NAME="IDX186"></A>
200 <A NAME="IDX187"></A>
201 Entries from <VAR>file</VAR> are not extracted.  <VAR>file</VAR> should be a PO or
202 POT file.
203
204 <DT><SAMP>&lsquo;-c[<VAR>tag</VAR>]&rsquo;</SAMP>
205 <DD>
206 <DT><SAMP>&lsquo;--add-comments[=<VAR>tag</VAR>]&rsquo;</SAMP>
207 <DD>
208 <A NAME="IDX188"></A>
209 <A NAME="IDX189"></A>
210 Place comment blocks starting with <VAR>tag</VAR> and preceding keyword lines
211 in the output file.  Without a <VAR>tag</VAR>, the option means to put <EM>all</EM>
212 comment blocks preceding keyword lines in the output file.
213
214 Note that comment blocks supposed to be extracted must be adjacent to
215 keyword lines.  For example, in the following C source code:
216
217
218 <PRE>
219 /* This is the first comment.  */
220 gettext ("foo");
221
222 /* This is the second comment: not extracted  */
223 gettext (
224   "bar");
225
226 gettext (
227   /* This is the third comment.  */
228   "baz");
229 </PRE>
230
231 The second comment line will not be extracted, because there is one
232 blank line between the comment line and the keyword.
233
234 <DT><SAMP>&lsquo;--check[=<VAR>CHECK</VAR>]&rsquo;</SAMP>
235 <DD>
236 <A NAME="IDX190"></A>
237 <A NAME="IDX191"></A>
238 Perform a syntax check on msgid and msgid_plural.  The supported checks
239 are:
240
241 <DL COMPACT>
242
243 <DT><SAMP>&lsquo;ellipsis-unicode&rsquo;</SAMP>
244 <DD>
245 Prefer Unicode ellipsis character over ASCII <CODE>...</CODE>
246
247 <DT><SAMP>&lsquo;space-ellipsis&rsquo;</SAMP>
248 <DD>
249 Prohibit whitespace before an ellipsis character
250
251 <DT><SAMP>&lsquo;quote-unicode&rsquo;</SAMP>
252 <DD>
253 Prefer Unicode quotation marks over ASCII <CODE>"'`</CODE>
254
255 <DT><SAMP>&lsquo;bullet-unicode&rsquo;</SAMP>
256 <DD>
257 Prefer Unicode bullet character over ASCII <CODE>*</CODE> or <CODE>-</CODE>
258
259 </DL>
260
261 The option has an effect on all input files.  To enable or disable
262 checks for a certain string, you can mark it with an <CODE>xgettext:</CODE>
263 special comment in the source file.  For example, if you specify the
264 <CODE>--check=space-ellipsis</CODE> option, but want to suppress the check on
265 a particular string, add the following comment:
266
267
268 <PRE>
269 /* xgettext: no-space-ellipsis-check */
270 gettext ("We really want a space before ellipsis here ...");
271 </PRE>
272
273 The <CODE>xgettext:</CODE> comment can be followed by flags separated with a
274 comma.  The possible flags are of the form <SAMP>&lsquo;[no-]<VAR>name</VAR>-check&rsquo;</SAMP>,
275 where <VAR>name</VAR> is the name of a valid syntax check.  If a flag is
276 prefixed by <CODE>no-</CODE>, the meaning is negated.
277
278 Some tests apply the checks to each sentence within the msgid, rather
279 than the whole string.  xgettext detects the end of sentence by
280 performing a pattern match, which usually looks for a period followed by
281 a certain number of spaces.  The number is specified with the
282 <CODE>--sentence-end</CODE> option.
283
284 <DT><SAMP>&lsquo;--sentence-end[=<VAR>TYPE</VAR>]&rsquo;</SAMP>
285 <DD>
286 <A NAME="IDX192"></A>
287 <A NAME="IDX193"></A>
288 The supported values are:
289
290 <DL COMPACT>
291
292 <DT><SAMP>&lsquo;single-space&rsquo;</SAMP>
293 <DD>
294 Expect at least one whitespace after a period
295
296 <DT><SAMP>&lsquo;double-space&rsquo;</SAMP>
297 <DD>
298 Expect at least two whitespaces after a period
299
300 </DL>
301
302 </DL>
303
304
305
306 <H3><A NAME="SEC34" HREF="gettext_toc.html#TOC34">5.1.6  Language specific options</A></H3>
307
308 <DL COMPACT>
309
310 <DT><SAMP>&lsquo;-a&rsquo;</SAMP>
311 <DD>
312 <DT><SAMP>&lsquo;--extract-all&rsquo;</SAMP>
313 <DD>
314 <A NAME="IDX194"></A>
315 <A NAME="IDX195"></A>
316 Extract all strings.
317
318 This option has an effect with most languages, namely C, C++, ObjectiveC,
319 Shell, Python, Lisp, EmacsLisp, librep, Java, C#, awk, Tcl, Perl, PHP,
320 GCC-source, Glade, Lua, JavaScript, Vala, GSettings.
321
322 <DT><SAMP>&lsquo;-k[<VAR>keywordspec</VAR>]&rsquo;</SAMP>
323 <DD>
324 <DT><SAMP>&lsquo;--keyword[=<VAR>keywordspec</VAR>]&rsquo;</SAMP>
325 <DD>
326 <A NAME="IDX196"></A>
327 <A NAME="IDX197"></A>
328 Specify <VAR>keywordspec</VAR> as an additional keyword to be looked for.
329 Without a <VAR>keywordspec</VAR>, the option means to not use default keywords.
330
331 <A NAME="IDX198"></A>
332 <A NAME="IDX199"></A>
333 If <VAR>keywordspec</VAR> is a C identifier <VAR>id</VAR>, <CODE>xgettext</CODE> looks
334 for strings in the first argument of each call to the function or macro
335 <VAR>id</VAR>.  If <VAR>keywordspec</VAR> is of the form
336 <SAMP>&lsquo;<VAR>id</VAR>:<VAR>argnum</VAR>&rsquo;</SAMP>, <CODE>xgettext</CODE> looks for strings in the
337 <VAR>argnum</VAR>th argument of the call.  If <VAR>keywordspec</VAR> is of the form
338 <SAMP>&lsquo;<VAR>id</VAR>:<VAR>argnum1</VAR>,<VAR>argnum2</VAR>&rsquo;</SAMP>, <CODE>xgettext</CODE> looks for
339 strings in the <VAR>argnum1</VAR>st argument and in the <VAR>argnum2</VAR>nd argument
340 of the call, and treats them as singular/plural variants for a message
341 with plural handling.  Also, if <VAR>keywordspec</VAR> is of the form
342 <SAMP>&lsquo;<VAR>id</VAR>:<VAR>contextargnum</VAR>c,<VAR>argnum</VAR>&rsquo;</SAMP> or
343 <SAMP>&lsquo;<VAR>id</VAR>:<VAR>argnum</VAR>,<VAR>contextargnum</VAR>c&rsquo;</SAMP>, <CODE>xgettext</CODE> treats
344 strings in the <VAR>contextargnum</VAR>th argument as a context specifier.
345 And, as a special-purpose support for GNOME, if <VAR>keywordspec</VAR> is of the
346 form <SAMP>&lsquo;<VAR>id</VAR>:<VAR>argnum</VAR>g&rsquo;</SAMP>, <CODE>xgettext</CODE> recognizes the
347 <VAR>argnum</VAR>th argument as a string with context, using the GNOME <CODE>glib</CODE>
348 syntax <SAMP>&lsquo;"msgctxt|msgid"&rsquo;</SAMP>.
349 <BR>
350 Furthermore, if <VAR>keywordspec</VAR> is of the form
351 <SAMP>&lsquo;<VAR>id</VAR>:...,<VAR>totalnumargs</VAR>t&rsquo;</SAMP>, <CODE>xgettext</CODE> recognizes this
352 argument specification only if the number of actual arguments is equal to
353 <VAR>totalnumargs</VAR>.  This is useful for disambiguating overloaded function
354 calls in C++.
355 <BR>
356 Finally, if <VAR>keywordspec</VAR> is of the form
357 <SAMP>&lsquo;<VAR>id</VAR>:<VAR>argnum</VAR>...,"<VAR>xcomment</VAR>"&rsquo;</SAMP>, <CODE>xgettext</CODE>, when
358 extracting a message from the specified argument strings, adds an extracted
359 comment <VAR>xcomment</VAR> to the message.  Note that when used through a normal
360 shell command line, the double-quotes around the <VAR>xcomment</VAR> need to be
361 escaped.
362
363 This option has an effect with most languages, namely C, C++, ObjectiveC,
364 Shell, Python, Lisp, EmacsLisp, librep, Java, C#, awk, Tcl, Perl, PHP,
365 GCC-source, Glade, Lua, JavaScript, Vala, GSettings, Desktop.
366
367 The default keyword specifications, which are always looked for if not
368 explicitly disabled, are language dependent.  They are:
369
370
371 <UL>
372 <LI>
373
374 For C, C++, and GCC-source: <CODE>gettext</CODE>, <CODE>dgettext:2</CODE>,
375 <CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
376 <CODE>dcngettext:2,3</CODE>, <CODE>gettext_noop</CODE>, and <CODE>pgettext:1c,2</CODE>,
377 <CODE>dpgettext:2c,3</CODE>, <CODE>dcpgettext:2c,3</CODE>, <CODE>npgettext:1c,2,3</CODE>,
378 <CODE>dnpgettext:2c,3,4</CODE>, <CODE>dcnpgettext:2c,3,4</CODE>.
379
380 <LI>
381
382 For Objective C: Like for C, and also <CODE>NSLocalizedString</CODE>, <CODE>_</CODE>,
383 <CODE>NSLocalizedStaticString</CODE>, <CODE>__</CODE>.
384
385 <LI>
386
387 For Shell scripts: <CODE>gettext</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>eval_gettext</CODE>,
388 <CODE>eval_ngettext:1,2</CODE>.
389
390 <LI>
391
392 For Python: <CODE>gettext</CODE>, <CODE>ugettext</CODE>, <CODE>dgettext:2</CODE>,
393 <CODE>ngettext:1,2</CODE>, <CODE>ungettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>, <CODE>_</CODE>.
394
395 <LI>
396
397 For Lisp: <CODE>gettext</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>gettext-noop</CODE>.
398
399 <LI>
400
401 For EmacsLisp: <CODE>_</CODE>.
402
403 <LI>
404
405 For librep: <CODE>_</CODE>.
406
407 <LI>
408
409 For Scheme: <CODE>gettext</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>gettext-noop</CODE>.
410
411 <LI>
412
413 For Java: <CODE>GettextResource.gettext:2</CODE>,
414 <CODE>GettextResource.ngettext:2,3</CODE>, <CODE>GettextResource.pgettext:2c,3</CODE>,
415 <CODE>GettextResource.npgettext:2c,3,4</CODE>, <CODE>gettext</CODE>, <CODE>ngettext:1,2</CODE>,
416 <CODE>pgettext:1c,2</CODE>, <CODE>npgettext:1c,2,3</CODE>, <CODE>getString</CODE>.
417
418 <LI>
419
420 For C#: <CODE>GetString</CODE>, <CODE>GetPluralString:1,2</CODE>,
421 <CODE>GetParticularString:1c,2</CODE>, <CODE>GetParticularPluralString:1c,2,3</CODE>.
422
423 <LI>
424
425 For awk: <CODE>dcgettext</CODE>, <CODE>dcngettext:1,2</CODE>.
426
427 <LI>
428
429 For Tcl: <CODE>::msgcat::mc</CODE>.
430
431 <LI>
432
433 For Perl: <CODE>gettext</CODE>, <CODE>%gettext</CODE>, <CODE>$gettext</CODE>, <CODE>dgettext:2</CODE>,
434 <CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
435 <CODE>dcngettext:2,3</CODE>, <CODE>gettext_noop</CODE>.
436
437 <LI>
438
439 For PHP: <CODE>_</CODE>, <CODE>gettext</CODE>, <CODE>dgettext:2</CODE>, <CODE>dcgettext:2</CODE>,
440 <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>, <CODE>dcngettext:2,3</CODE>.
441
442 <LI>
443
444 For Glade 1: <CODE>label</CODE>, <CODE>title</CODE>, <CODE>text</CODE>, <CODE>format</CODE>,
445 <CODE>copyright</CODE>, <CODE>comments</CODE>, <CODE>preview_text</CODE>, <CODE>tooltip</CODE>.
446
447 <LI>
448
449 For Lua: <CODE>_</CODE>, <CODE>gettext.gettext</CODE>, <CODE>gettext.dgettext:2</CODE>,
450 <CODE>gettext.dcgettext:2</CODE>, <CODE>gettext.ngettext:1,2</CODE>,
451 <CODE>gettext.dngettext:2,3</CODE>, <CODE>gettext.dcngettext:2,3</CODE>.
452
453 <LI>
454
455 For JavaScript: <CODE>_</CODE>, <CODE>gettext</CODE>, <CODE>dgettext:2</CODE>,
456 <CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
457 <CODE>pgettext:1c,2</CODE>, <CODE>dpgettext:2c,3</CODE>.
458
459 <LI>
460
461 For Vala: <CODE>_</CODE>, <CODE>Q_</CODE>, <CODE>N_</CODE>, <CODE>NC_</CODE>, <CODE>dgettext:2</CODE>,
462 <CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
463 <CODE>dpgettext:2c,3</CODE>, <CODE>dpgettext2:2c,3</CODE>.
464
465 <LI>
466
467 For Desktop: <CODE>Name</CODE>, <CODE>GenericName</CODE>, <CODE>Comment</CODE>,
468 <CODE>Icon</CODE>, <CODE>Keywords</CODE>.
469 </UL>
470
471 To disable the default keyword specifications, the option <SAMP>&lsquo;-k&rsquo;</SAMP> or
472 <SAMP>&lsquo;--keyword&rsquo;</SAMP> or <SAMP>&lsquo;--keyword=&rsquo;</SAMP>, without a <VAR>keywordspec</VAR>, can be
473 used.
474
475 <DT><SAMP>&lsquo;--flag=<VAR>word</VAR>:<VAR>arg</VAR>:<VAR>flag</VAR>&rsquo;</SAMP>
476 <DD>
477 <A NAME="IDX200"></A>
478 Specifies additional flags for strings occurring as part of the <VAR>arg</VAR>th
479 argument of the function <VAR>word</VAR>.  The possible flags are the possible
480 format string indicators, such as <SAMP>&lsquo;c-format&rsquo;</SAMP>, and their negations,
481 such as <SAMP>&lsquo;no-c-format&rsquo;</SAMP>, possibly prefixed with <SAMP>&lsquo;pass-&rsquo;</SAMP>.
482 <BR>
483 <A NAME="IDX201"></A>
484 The meaning of <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:<VAR>lang</VAR>-format</CODE>
485 is that in language <VAR>lang</VAR>, the specified <VAR>function</VAR> expects as
486 <VAR>arg</VAR>th argument a format string.  (For those of you familiar with
487 GCC function attributes, <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:c-format</CODE> is
488 roughly equivalent to the declaration
489 <SAMP>&lsquo;__attribute__ ((__format__ (__printf__, <VAR>arg</VAR>, ...)))&rsquo;</SAMP> attached
490 to <VAR>function</VAR> in a C source file.)
491 For example, if you use the <SAMP>&lsquo;error&rsquo;</SAMP> function from GNU libc, you can
492 specify its behaviour through <CODE>--flag=error:3:c-format</CODE>.  The effect of
493 this specification is that <CODE>xgettext</CODE> will mark as format strings all
494 <CODE>gettext</CODE> invocations that occur as <VAR>arg</VAR>th argument of
495 <VAR>function</VAR>.
496 This is useful when such strings contain no format string directives:
497 together with the checks done by <SAMP>&lsquo;msgfmt -c&rsquo;</SAMP> it will ensure that
498 translators cannot accidentally use format string directives that would
499 lead to a crash at runtime.
500 <BR>
501 <A NAME="IDX202"></A>
502 The meaning of <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:pass-<VAR>lang</VAR>-format</CODE>
503 is that in language <VAR>lang</VAR>, if the <VAR>function</VAR> call occurs in a
504 position that must yield a format string, then its <VAR>arg</VAR>th argument
505 must yield a format string of the same type as well.  (If you know GCC
506 function attributes, the <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:pass-c-format</CODE>
507 option is roughly equivalent to the declaration
508 <SAMP>&lsquo;__attribute__ ((__format_arg__ (<VAR>arg</VAR>)))&rsquo;</SAMP> attached to <VAR>function</VAR>
509 in a C source file.)
510 For example, if you use the <SAMP>&lsquo;_&rsquo;</SAMP> shortcut for the <CODE>gettext</CODE> function,
511 you should use <CODE>--flag=_:1:pass-c-format</CODE>.  The effect of this
512 specification is that <CODE>xgettext</CODE> will propagate a format string
513 requirement for a <CODE>_("string")</CODE> call to its first argument, the literal
514 <CODE>"string"</CODE>, and thus mark it as a format string.
515 This is useful when such strings contain no format string directives:
516 together with the checks done by <SAMP>&lsquo;msgfmt -c&rsquo;</SAMP> it will ensure that
517 translators cannot accidentally use format string directives that would
518 lead to a crash at runtime.
519 <BR>
520 This option has an effect with most languages, namely C, C++, ObjectiveC,
521 Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, YCP, Tcl, Perl, PHP,
522 GCC-source, Lua, JavaScript, Vala.
523
524 <DT><SAMP>&lsquo;-T&rsquo;</SAMP>
525 <DD>
526 <DT><SAMP>&lsquo;--trigraphs&rsquo;</SAMP>
527 <DD>
528 <A NAME="IDX203"></A>
529 <A NAME="IDX204"></A>
530 <A NAME="IDX205"></A>
531 Understand ANSI C trigraphs for input.
532 <BR>
533 This option has an effect only with the languages C, C++, ObjectiveC.
534
535 <DT><SAMP>&lsquo;--qt&rsquo;</SAMP>
536 <DD>
537 <A NAME="IDX206"></A>
538 <A NAME="IDX207"></A>
539 Recognize Qt format strings.
540 <BR>
541 This option has an effect only with the language C++.
542
543 <DT><SAMP>&lsquo;--kde&rsquo;</SAMP>
544 <DD>
545 <A NAME="IDX208"></A>
546 <A NAME="IDX209"></A>
547 Recognize KDE 4 format strings.
548 <BR>
549 This option has an effect only with the language C++.
550
551 <DT><SAMP>&lsquo;--boost&rsquo;</SAMP>
552 <DD>
553 <A NAME="IDX210"></A>
554 <A NAME="IDX211"></A>
555 Recognize Boost format strings.
556 <BR>
557 This option has an effect only with the language C++.
558
559 <DT><SAMP>&lsquo;--debug&rsquo;</SAMP>
560 <DD>
561 <A NAME="IDX212"></A>
562 <A NAME="IDX213"></A>
563 Use the flags <CODE>c-format</CODE> and <CODE>possible-c-format</CODE> to show who was
564 responsible for marking a message as a format string.  The latter form is
565 used if the <CODE>xgettext</CODE> program decided, the former form is used if
566 the programmer prescribed it.
567
568 By default only the <CODE>c-format</CODE> form is used.  The translator should
569 not have to care about these details.
570
571 </DL>
572
573 <P>
574 This implementation of <CODE>xgettext</CODE> is able to process a few awkward
575 cases, like strings in preprocessor macros, ANSI concatenation of
576 adjacent strings, and escaped end of lines for continued strings.
577
578 </P>
579
580
581 <H3><A NAME="SEC35" HREF="gettext_toc.html#TOC35">5.1.7  Output details</A></H3>
582
583 <DL COMPACT>
584
585 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
586 <DD>
587 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
588 <DD>
589 <A NAME="IDX214"></A>
590 Specify whether or when to use colors and other text attributes.
591 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
592
593 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
594 <DD>
595 <A NAME="IDX215"></A>
596 Specify the CSS style rule file to use for <CODE>--color</CODE>.
597 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
598
599 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
600 <DD>
601 <A NAME="IDX216"></A>
602 Always write an output file even if no message is defined.
603
604 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
605 <DD>
606 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
607 <DD>
608 <A NAME="IDX217"></A>
609 <A NAME="IDX218"></A>
610 Write the .po file using indented style.
611
612 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
613 <DD>
614 <A NAME="IDX219"></A>
615 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.  Note that using
616 this option makes it harder for technically skilled translators to understand
617 each message's context.
618
619 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
620 <DD>
621 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
622 <DD>
623 <A NAME="IDX220"></A>
624 <A NAME="IDX221"></A>
625 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
626
627 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
628 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
629 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
630 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
631 suppresses the lines (same as <CODE>--no-location</CODE>).
632
633 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
634 <DD>
635 <A NAME="IDX222"></A>
636 Write out a strict Uniforum conforming PO file.  Note that this
637 Uniforum format should be avoided because it doesn't support the
638 GNU extensions.
639
640 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
641 <DD>
642 <A NAME="IDX223"></A>
643 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
644 that this file format doesn't support plural forms and silently drops
645 obsolete messages.
646
647 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
648 <DD>
649 <A NAME="IDX224"></A>
650 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
651 Note that this file format doesn't support plural forms.
652
653 <DT><SAMP>&lsquo;--its=<VAR>file</VAR>&rsquo;</SAMP>
654 <DD>
655 <A NAME="IDX225"></A>
656 Use ITS rules defined in <VAR>file</VAR>.
657 Note that this is only effective with XML files.
658
659 <DT><SAMP>&lsquo;--itstool&rsquo;</SAMP>
660 <DD>
661 <A NAME="IDX226"></A>
662 Write out comments recognized by itstool (<A HREF="http://itstool.org">http://itstool.org</A>).
663 Note that this is only effective with XML files.
664
665 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
666 <DD>
667 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
668 <DD>
669 <A NAME="IDX227"></A>
670 <A NAME="IDX228"></A>
671 Set the output page width.  Long strings in the output files will be
672 split across multiple lines in order to ensure that each line's width
673 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
674
675 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
676 <DD>
677 <A NAME="IDX229"></A>
678 Do not break long message lines.  Message lines whose width exceeds the
679 output page width will not be split into several lines.  Only file reference
680 lines which are wider than the output page width will be split.
681
682 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
683 <DD>
684 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
685 <DD>
686 <A NAME="IDX230"></A>
687 <A NAME="IDX231"></A>
688 <A NAME="IDX232"></A>
689 Generate sorted output.  Note that using this option makes it much harder
690 for the translator to understand each message's context.
691
692 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
693 <DD>
694 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
695 <DD>
696 <A NAME="IDX233"></A>
697 <A NAME="IDX234"></A>
698 Sort output by file location.
699
700 <DT><SAMP>&lsquo;--omit-header&rsquo;</SAMP>
701 <DD>
702 <A NAME="IDX235"></A>
703 Don't write header with <SAMP>&lsquo;msgid ""&rsquo;</SAMP> entry.
704
705 <A NAME="IDX236"></A>
706 This is useful for testing purposes because it eliminates a source
707 of variance for generated <CODE>.gmo</CODE> files.  With <CODE>--omit-header</CODE>,
708 two invocations of <CODE>xgettext</CODE> on the same files with the same
709 options at different times are guaranteed to produce the same results.
710
711 Note that using this option will lead to an error if the resulting file
712 would not entirely be in ASCII.
713
714 <DT><SAMP>&lsquo;--copyright-holder=<VAR>string</VAR>&rsquo;</SAMP>
715 <DD>
716 <A NAME="IDX237"></A>
717 Set the copyright holder in the output.  <VAR>string</VAR> should be the
718 copyright holder of the surrounding package.  (Note that the msgstr
719 strings, extracted from the package's sources, belong to the copyright
720 holder of the package.)  Translators are expected to transfer or disclaim
721 the copyright for their translations, so that package maintainers can
722 distribute them without legal risk.  If <VAR>string</VAR> is empty, the output
723 files are marked as being in the public domain; in this case, the translators
724 are expected to disclaim their copyright, again so that package maintainers
725 can distribute them without legal risk.
726
727 The default value for <VAR>string</VAR> is the Free Software Foundation, Inc.,
728 simply because <CODE>xgettext</CODE> was first used in the GNU project.
729
730 <DT><SAMP>&lsquo;--foreign-user&rsquo;</SAMP>
731 <DD>
732 <A NAME="IDX238"></A>
733 Omit FSF copyright in output.  This option is equivalent to
734 <SAMP>&lsquo;--copyright-holder=”&rsquo;</SAMP>.  It can be useful for packages outside the GNU
735 project that want their translations to be in the public domain.
736
737 <DT><SAMP>&lsquo;--package-name=<VAR>package</VAR>&rsquo;</SAMP>
738 <DD>
739 <A NAME="IDX239"></A>
740 Set the package name in the header of the output.
741
742 <DT><SAMP>&lsquo;--package-version=<VAR>version</VAR>&rsquo;</SAMP>
743 <DD>
744 <A NAME="IDX240"></A>
745 Set the package version in the header of the output.  This option has an
746 effect only if the <SAMP>&lsquo;--package-name&rsquo;</SAMP> option is also used.
747
748 <DT><SAMP>&lsquo;--msgid-bugs-address=<VAR>email@address</VAR>&rsquo;</SAMP>
749 <DD>
750 <A NAME="IDX241"></A>
751 Set the reporting address for msgid bugs.  This is the email address or URL
752 to which the translators shall report bugs in the untranslated strings:
753
754
755 <UL>
756 <LI>Strings which are not entire sentences; see the maintainer guidelines
757
758 in section <A HREF="gettext_4.html#SEC19">4.3  Preparing Translatable Strings</A>.
759 <LI>Strings which use unclear terms or require additional context to be
760
761 understood.
762 <LI>Strings which make invalid assumptions about notation of date, time or
763
764 money.
765 <LI>Pluralisation problems.
766
767 <LI>Incorrect English spelling.
768
769 <LI>Incorrect formatting.
770
771 </UL>
772
773 It can be your email address, or a mailing list address where translators
774 can write to without being subscribed, or the URL of a web page through
775 which the translators can contact you.
776
777 The default value is empty, which means that translators will be clueless!
778 Don't forget to specify this option.
779
780 <DT><SAMP>&lsquo;-m[<VAR>string</VAR>]&rsquo;</SAMP>
781 <DD>
782 <DT><SAMP>&lsquo;--msgstr-prefix[=<VAR>string</VAR>]&rsquo;</SAMP>
783 <DD>
784 <A NAME="IDX242"></A>
785 <A NAME="IDX243"></A>
786 Use <VAR>string</VAR> (or "" if not specified) as prefix for msgstr values.
787
788 <DT><SAMP>&lsquo;-M[<VAR>string</VAR>]&rsquo;</SAMP>
789 <DD>
790 <DT><SAMP>&lsquo;--msgstr-suffix[=<VAR>string</VAR>]&rsquo;</SAMP>
791 <DD>
792 <A NAME="IDX244"></A>
793 <A NAME="IDX245"></A>
794 Use <VAR>string</VAR> (or "" if not specified) as suffix for msgstr values.
795
796 </DL>
797
798
799
800 <H3><A NAME="SEC36" HREF="gettext_toc.html#TOC36">5.1.8  Informative output</A></H3>
801
802 <DL COMPACT>
803
804 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
805 <DD>
806 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
807 <DD>
808 <A NAME="IDX246"></A>
809 <A NAME="IDX247"></A>
810 Display this help and exit.
811
812 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
813 <DD>
814 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
815 <DD>
816 <A NAME="IDX248"></A>
817 <A NAME="IDX249"></A>
818 Output version information and exit.
819
820 </DL>
821
822 <P><HR><P>
823 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_4.html">previous</A>, <A HREF="gettext_6.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
824 </BODY>
825 </HTML>