transmision: upgrade 2.22 -> 2.31
[tomato.git] / release / src / router / gettext / gettext-tools / doc / gettext_4.html
blob4066ac7980cd2bc8c83062ede726f270d36e2efd
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.52a
4 from gettext.texi on 23 May 2005 -->
6 <TITLE>GNU gettext utilities - 4 Making the PO Template File</TITLE>
7 </HEAD>
8 <BODY>
9 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_22.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
10 <P><HR><P>
13 <H1><A NAME="SEC22" HREF="gettext_toc.html#TOC22">4 Making the PO Template File</A></H1>
14 <P>
15 <A NAME="IDX188"></A>
17 </P>
18 <P>
19 After preparing the sources, the programmer creates a PO template file.
20 This section explains how to use <CODE>xgettext</CODE> for this purpose.
22 </P>
23 <P>
24 <CODE>xgettext</CODE> creates a file named <TT>`<VAR>domainname</VAR>.po&acute;</TT>. You
25 should then rename it to <TT>`<VAR>domainname</VAR>.pot&acute;</TT>. (Why doesn't
26 <CODE>xgettext</CODE> create it under the name <TT>`<VAR>domainname</VAR>.pot&acute;</TT>
27 right away? The answer is: for historical reasons. When <CODE>xgettext</CODE>
28 was specified, the distinction between a PO file and PO file template
29 was fuzzy, and the suffix <SAMP>`.pot&acute;</SAMP> wasn't in use at that time.)
31 </P>
35 <H2><A NAME="SEC23" HREF="gettext_toc.html#TOC23">4.1 Invoking the <CODE>xgettext</CODE> Program</A></H2>
37 <P>
38 <A NAME="IDX189"></A>
39 <A NAME="IDX190"></A>
41 <PRE>
42 xgettext [<VAR>option</VAR>] [<VAR>inputfile</VAR>] ...
43 </PRE>
45 <P>
46 The <CODE>xgettext</CODE> program extracts translatable strings from given
47 input files.
49 </P>
52 <H3><A NAME="SEC24" HREF="gettext_toc.html#TOC24">4.1.1 Input file location</A></H3>
54 <DL COMPACT>
56 <DT><SAMP>`<VAR>inputfile</VAR> ...&acute;</SAMP>
57 <DD>
58 Input files.
60 <DT><SAMP>`-f <VAR>file</VAR>&acute;</SAMP>
61 <DD>
62 <DT><SAMP>`--files-from=<VAR>file</VAR>&acute;</SAMP>
63 <DD>
64 <A NAME="IDX191"></A>
65 <A NAME="IDX192"></A>
66 Read the names of the input files from <VAR>file</VAR> instead of getting
67 them from the command line.
69 <DT><SAMP>`-D <VAR>directory</VAR>&acute;</SAMP>
70 <DD>
71 <DT><SAMP>`--directory=<VAR>directory</VAR>&acute;</SAMP>
72 <DD>
73 <A NAME="IDX193"></A>
74 <A NAME="IDX194"></A>
75 Add <VAR>directory</VAR> to the list of directories. Source files are
76 searched relative to this list of directories. The resulting <TT>`.po&acute;</TT>
77 file will be written relative to the current directory, though.
79 </DL>
81 <P>
82 If <VAR>inputfile</VAR> is <SAMP>`-&acute;</SAMP>, standard input is read.
84 </P>
87 <H3><A NAME="SEC25" HREF="gettext_toc.html#TOC25">4.1.2 Output file location</A></H3>
89 <DL COMPACT>
91 <DT><SAMP>`-d <VAR>name</VAR>&acute;</SAMP>
92 <DD>
93 <DT><SAMP>`--default-domain=<VAR>name</VAR>&acute;</SAMP>
94 <DD>
95 <A NAME="IDX195"></A>
96 <A NAME="IDX196"></A>
97 Use <TT>`<VAR>name</VAR>.po&acute;</TT> for output (instead of <TT>`messages.po&acute;</TT>).
99 <DT><SAMP>`-o <VAR>file</VAR>&acute;</SAMP>
100 <DD>
101 <DT><SAMP>`--output=<VAR>file</VAR>&acute;</SAMP>
102 <DD>
103 <A NAME="IDX197"></A>
104 <A NAME="IDX198"></A>
105 Write output to specified file (instead of <TT>`<VAR>name</VAR>.po&acute;</TT> or
106 <TT>`messages.po&acute;</TT>).
108 <DT><SAMP>`-p <VAR>dir</VAR>&acute;</SAMP>
109 <DD>
110 <DT><SAMP>`--output-dir=<VAR>dir</VAR>&acute;</SAMP>
111 <DD>
112 <A NAME="IDX199"></A>
113 <A NAME="IDX200"></A>
114 Output files will be placed in directory <VAR>dir</VAR>.
116 </DL>
119 <A NAME="IDX201"></A>
120 If the output <VAR>file</VAR> is <SAMP>`-&acute;</SAMP> or <SAMP>`/dev/stdout&acute;</SAMP>, the output
121 is written to standard output.
123 </P>
126 <H3><A NAME="SEC26" HREF="gettext_toc.html#TOC26">4.1.3 Choice of input file language</A></H3>
128 <DL COMPACT>
130 <DT><SAMP>`-L <VAR>name</VAR>&acute;</SAMP>
131 <DD>
132 <DT><SAMP>`--language=<VAR>name</VAR>&acute;</SAMP>
133 <DD>
134 <A NAME="IDX202"></A>
135 <A NAME="IDX203"></A>
136 <A NAME="IDX204"></A>
137 Specifies the language of the input files. The supported languages
138 are <CODE>C</CODE>, <CODE>C++</CODE>, <CODE>ObjectiveC</CODE>, <CODE>PO</CODE>, <CODE>Python</CODE>,
139 <CODE>Lisp</CODE>, <CODE>EmacsLisp</CODE>, <CODE>librep</CODE>, <CODE>Scheme</CODE>, <CODE>Smalltalk</CODE>,
140 <CODE>Java</CODE>, <CODE>JavaProperties</CODE>, <CODE>C#</CODE>, <CODE>awk</CODE>, <CODE>YCP</CODE>,
141 <CODE>Tcl</CODE>, <CODE>Perl</CODE>, <CODE>PHP</CODE>, <CODE>GCC-source</CODE>, <CODE>NXStringTable</CODE>,
142 <CODE>RST</CODE>, <CODE>Glade</CODE>.
144 <DT><SAMP>`-C&acute;</SAMP>
145 <DD>
146 <DT><SAMP>`--c++&acute;</SAMP>
147 <DD>
148 <A NAME="IDX205"></A>
149 <A NAME="IDX206"></A>
150 This is a shorthand for <CODE>--language=C++</CODE>.
152 </DL>
155 By default the language is guessed depending on the input file name
156 extension.
158 </P>
161 <H3><A NAME="SEC27" HREF="gettext_toc.html#TOC27">4.1.4 Input file interpretation</A></H3>
163 <DL COMPACT>
165 <DT><SAMP>`--from-code=<VAR>name</VAR>&acute;</SAMP>
166 <DD>
167 <A NAME="IDX207"></A>
168 Specifies the encoding of the input files. This option is needed only
169 if some untranslated message strings or their corresponding comments
170 contain non-ASCII characters. Note that Python, Tcl, and Glade input
171 files are always assumed to be in UTF-8, regardless of this option.
173 </DL>
176 By default the input files are assumed to be in ASCII.
178 </P>
181 <H3><A NAME="SEC28" HREF="gettext_toc.html#TOC28">4.1.5 Operation mode</A></H3>
183 <DL COMPACT>
185 <DT><SAMP>`-j&acute;</SAMP>
186 <DD>
187 <DT><SAMP>`--join-existing&acute;</SAMP>
188 <DD>
189 <A NAME="IDX208"></A>
190 <A NAME="IDX209"></A>
191 Join messages with existing file.
193 <DT><SAMP>`-x <VAR>file</VAR>&acute;</SAMP>
194 <DD>
195 <DT><SAMP>`--exclude-file=<VAR>file</VAR>&acute;</SAMP>
196 <DD>
197 <A NAME="IDX210"></A>
198 <A NAME="IDX211"></A>
199 Entries from <VAR>file</VAR> are not extracted. <VAR>file</VAR> should be a PO or
200 POT file.
202 <DT><SAMP>`-c [<VAR>tag</VAR>]&acute;</SAMP>
203 <DD>
204 <DT><SAMP>`--add-comments[=<VAR>tag</VAR>]&acute;</SAMP>
205 <DD>
206 <A NAME="IDX212"></A>
207 <A NAME="IDX213"></A>
208 Place comment block with <VAR>tag</VAR> (or those preceding keyword lines)
209 in output file.
211 </DL>
215 <H3><A NAME="SEC29" HREF="gettext_toc.html#TOC29">4.1.6 Language specific options</A></H3>
217 <DL COMPACT>
219 <DT><SAMP>`-a&acute;</SAMP>
220 <DD>
221 <DT><SAMP>`--extract-all&acute;</SAMP>
222 <DD>
223 <A NAME="IDX214"></A>
224 <A NAME="IDX215"></A>
225 Extract all strings.
227 This option has an effect with most languages, namely C, C++, ObjectiveC,
228 Shell, Python, Lisp, EmacsLisp, librep, Java, C#, awk, Tcl, Perl, PHP,
229 GCC-source, Glade.
231 <DT><SAMP>`-k <VAR>keywordspec</VAR>&acute;</SAMP>
232 <DD>
233 <DT><SAMP>`--keyword[=<VAR>keywordspec</VAR>]&acute;</SAMP>
234 <DD>
235 <A NAME="IDX216"></A>
236 <A NAME="IDX217"></A>
237 Additional keyword to be looked for (without <VAR>keywordspec</VAR> means not to
238 use default keywords).
240 <A NAME="IDX218"></A>
241 If <VAR>keywordspec</VAR> is a C identifer <VAR>id</VAR>, <CODE>xgettext</CODE> looks
242 for strings in the first argument of each call to the function or macro
243 <VAR>id</VAR>. If <VAR>keywordspec</VAR> is of the form
244 <SAMP>`<VAR>id</VAR>:<VAR>argnum</VAR>&acute;</SAMP>, <CODE>xgettext</CODE> looks for strings in the
245 <VAR>argnum</VAR>th argument of the call. If <VAR>keywordspec</VAR> is of the form
246 <SAMP>`<VAR>id</VAR>:<VAR>argnum1</VAR>,<VAR>argnum2</VAR>&acute;</SAMP>, <CODE>xgettext</CODE> looks for
247 strings in the <VAR>argnum1</VAR>st argument and in the <VAR>argnum2</VAR>nd argument
248 of the call, and treats them as singular/plural variants for a message
249 with plural handling.
250 <BR>
251 The default keyword specifications, which are always looked for if not
252 explicitly disabled, are <CODE>gettext</CODE>, <CODE>dgettext:2</CODE>,
253 <CODE>dcgettext:2</CODE>, <CODE>ngettext:1,2</CODE>, <CODE>dngettext:2,3</CODE>,
254 <CODE>dcngettext:2,3</CODE>, and <CODE>gettext_noop</CODE>.
255 <BR>
256 This option has an effect with most languages, namely C, C++, ObjectiveC,
257 Shell, Python, Lisp, EmacsLisp, librep, Java, C#, awk, Tcl, Perl, PHP,
258 GCC-source, Glade.
260 <DT><SAMP>`--flag=<VAR>word</VAR>:<VAR>arg</VAR>:<VAR>flag</VAR>&acute;</SAMP>
261 <DD>
262 <A NAME="IDX219"></A>
263 Specifies additional flags for strings occurring as part of the <VAR>arg</VAR>th
264 argument of the function <VAR>word</VAR>. The possible flags are the possible
265 format string indicators, such as <SAMP>`c-format&acute;</SAMP>, and their negations,
266 such as <SAMP>`no-c-format&acute;</SAMP>, possibly prefixed with <SAMP>`pass-&acute;</SAMP>.
267 <BR>
268 <A NAME="IDX220"></A>
269 The meaning of <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:<VAR>lang</VAR>-format</CODE>
270 is that in language <VAR>lang</VAR>, the specified <VAR>function</VAR> expects as
271 <VAR>arg</VAR>th argument a format string. (For those of you familiar with
272 GCC function attributes, <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:c-format</CODE> is
273 roughly equivalent to the declaration
274 <SAMP>`__attribute__ ((__format__ (__printf__, <VAR>arg</VAR>, ...)))&acute;</SAMP> attached
275 to <VAR>function</VAR> in a C source file.)
276 For example, if you use the <SAMP>`error&acute;</SAMP> function from GNU libc, you can
277 specify its behaviour through <CODE>--flag=error:3:c-format</CODE>. The effect of
278 this specification is that <CODE>xgettext</CODE> will mark as format strings all
279 <CODE>gettext</CODE> invocations that occur as <VAR>arg</VAR>th argument of
280 <VAR>function</VAR>.
281 This is useful when such strings contain no format string directives:
282 together with the checks done by <SAMP>`msgfmt -c&acute;</SAMP> it will ensure that
283 translators cannot accidentally use format string directives that would
284 lead to a crash at runtime.
285 <BR>
286 <A NAME="IDX221"></A>
287 The meaning of <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:pass-<VAR>lang</VAR>-format</CODE>
288 is that in language <VAR>lang</VAR>, if the <VAR>function</VAR> call occurs in a
289 position that must yield a format string, then its <VAR>arg</VAR>th argument
290 must yield a format string of the same type as well. (If you know GCC
291 function attributes, the <CODE>--flag=<VAR>function</VAR>:<VAR>arg</VAR>:pass-c-format</CODE>
292 option is roughly equivalent to the declaration
293 <SAMP>`__attribute__ ((__format_arg__ (<VAR>arg</VAR>)))&acute;</SAMP> attached to <VAR>function</VAR>
294 in a C source file.)
295 For example, if you use the <SAMP>`_&acute;</SAMP> shortcut for the <CODE>gettext</CODE> function,
296 you should use <CODE>--flag=_:1:pass-c-format</CODE>. The effect of this
297 specification is that <CODE>xgettext</CODE> will propagate a format string
298 requirement for a <CODE>_("string")</CODE> call to its first argument, the literal
299 <CODE>"string"</CODE>, and thus mark it as a format string.
300 This is useful when such strings contain no format string directives:
301 together with the checks done by <SAMP>`msgfmt -c&acute;</SAMP> it will ensure that
302 translators cannot accidentally use format string directives that would
303 lead to a crash at runtime.
304 <BR>
305 This option has an effect with most languages, namely C, C++, ObjectiveC,
306 Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, YCP, Tcl, Perl, PHP,
307 GCC-source.
309 <DT><SAMP>`-T&acute;</SAMP>
310 <DD>
311 <DT><SAMP>`--trigraphs&acute;</SAMP>
312 <DD>
313 <A NAME="IDX222"></A>
314 <A NAME="IDX223"></A>
315 <A NAME="IDX224"></A>
316 Understand ANSI C trigraphs for input.
317 <BR>
318 This option has an effect only with the languages C, C++, ObjectiveC.
320 <DT><SAMP>`--qt&acute;</SAMP>
321 <DD>
322 <A NAME="IDX225"></A>
323 <A NAME="IDX226"></A>
324 Recognize Qt format strings.
325 <BR>
326 This option has an effect only with the language C++.
328 <DT><SAMP>`--debug&acute;</SAMP>
329 <DD>
330 <A NAME="IDX227"></A>
331 <A NAME="IDX228"></A>
332 Use the flags <CODE>c-format</CODE> and <CODE>possible-c-format</CODE> to show who was
333 responsible for marking a message as a format string. The latter form is
334 used if the <CODE>xgettext</CODE> program decided, the format form is used if
335 the programmer prescribed it.
337 By default only the <CODE>c-format</CODE> form is used. The translator should
338 not have to care about these details.
340 </DL>
343 This implementation of <CODE>xgettext</CODE> is able to process a few awkward
344 cases, like strings in preprocessor macros, ANSI concatenation of
345 adjacent strings, and escaped end of lines for continued strings.
347 </P>
350 <H3><A NAME="SEC30" HREF="gettext_toc.html#TOC30">4.1.7 Output details</A></H3>
352 <DL COMPACT>
354 <DT><SAMP>`--force-po&acute;</SAMP>
355 <DD>
356 <A NAME="IDX229"></A>
357 Always write an output file even if no message is defined.
359 <DT><SAMP>`-i&acute;</SAMP>
360 <DD>
361 <DT><SAMP>`--indent&acute;</SAMP>
362 <DD>
363 <A NAME="IDX230"></A>
364 <A NAME="IDX231"></A>
365 Write the .po file using indented style.
367 <DT><SAMP>`--no-location&acute;</SAMP>
368 <DD>
369 <A NAME="IDX232"></A>
370 Do not write <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>&acute;</SAMP> lines.
372 <DT><SAMP>`-n&acute;</SAMP>
373 <DD>
374 <DT><SAMP>`--add-location&acute;</SAMP>
375 <DD>
376 <A NAME="IDX233"></A>
377 <A NAME="IDX234"></A>
378 Generate <SAMP>`#: <VAR>filename</VAR>:<VAR>line</VAR>&acute;</SAMP> lines (default).
380 <DT><SAMP>`--strict&acute;</SAMP>
381 <DD>
382 <A NAME="IDX235"></A>
383 Write out a strict Uniforum conforming PO file. Note that this
384 Uniforum format should be avoided because it doesn't support the
385 GNU extensions.
387 <DT><SAMP>`--properties-output&acute;</SAMP>
388 <DD>
389 <A NAME="IDX236"></A>
390 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax. Note
391 that this file format doesn't support plural forms and silently drops
392 obsolete messages.
394 <DT><SAMP>`--stringtable-output&acute;</SAMP>
395 <DD>
396 <A NAME="IDX237"></A>
397 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
398 Note that this file format doesn't support plural forms.
400 <DT><SAMP>`-w <VAR>number</VAR>&acute;</SAMP>
401 <DD>
402 <DT><SAMP>`--width=<VAR>number</VAR>&acute;</SAMP>
403 <DD>
404 <A NAME="IDX238"></A>
405 <A NAME="IDX239"></A>
406 Set the output page width. Long strings in the output files will be
407 split across multiple lines in order to ensure that each line's width
408 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
410 <DT><SAMP>`--no-wrap&acute;</SAMP>
411 <DD>
412 <A NAME="IDX240"></A>
413 Do not break long message lines. Message lines whose width exceeds the
414 output page width will not be split into several lines. Only file reference
415 lines which are wider than the output page width will be split.
417 <DT><SAMP>`-s&acute;</SAMP>
418 <DD>
419 <DT><SAMP>`--sort-output&acute;</SAMP>
420 <DD>
421 <A NAME="IDX241"></A>
422 <A NAME="IDX242"></A>
423 <A NAME="IDX243"></A>
424 Generate sorted output. Note that using this option makes it much harder
425 for the translator to understand each message's context.
427 <DT><SAMP>`-F&acute;</SAMP>
428 <DD>
429 <DT><SAMP>`--sort-by-file&acute;</SAMP>
430 <DD>
431 <A NAME="IDX244"></A>
432 <A NAME="IDX245"></A>
433 Sort output by file location.
435 <DT><SAMP>`--omit-header&acute;</SAMP>
436 <DD>
437 <A NAME="IDX246"></A>
438 Don't write header with <SAMP>`msgid ""&acute;</SAMP> entry.
440 <A NAME="IDX247"></A>
441 This is useful for testing purposes because it eliminates a source
442 of variance for generated <CODE>.gmo</CODE> files. With <CODE>--omit-header</CODE>,
443 two invocations of <CODE>xgettext</CODE> on the same files with the same
444 options at different times are guaranteed to produce the same results.
446 <DT><SAMP>`--copyright-holder=<VAR>string</VAR>&acute;</SAMP>
447 <DD>
448 <A NAME="IDX248"></A>
449 Set the copyright holder in the output. <VAR>string</VAR> should be the
450 copyright holder of the surrounding package. (Note that the msgstr
451 strings, extracted from the package's sources, belong to the copyright
452 holder of the package.) Translators are expected to transfer or disclaim
453 the copyright for their translations, so that package maintainers can
454 distribute them without legal risk. If <VAR>string</VAR> is empty, the output
455 files are marked as being in the public domain; in this case, the translators
456 are expected to disclaim their copyright, again so that package maintainers
457 can distribute them without legal risk.
459 The default value for <VAR>string</VAR> is the Free Software Foundation, Inc.,
460 simply because <CODE>xgettext</CODE> was first used in the GNU project.
462 <DT><SAMP>`--foreign-user&acute;</SAMP>
463 <DD>
464 <A NAME="IDX249"></A>
465 Omit FSF copyright in output. This option is equivalent to
466 <SAMP>`--copyright-holder="&acute;</SAMP>. It can be useful for packages outside the GNU
467 project that want their translations to be in the public domain.
469 <DT><SAMP>`--msgid-bugs-address=<VAR>email@address</VAR>&acute;</SAMP>
470 <DD>
471 <A NAME="IDX250"></A>
472 Set the reporting address for msgid bugs. This is the email address or URL
473 to which the translators shall report bugs in the untranslated strings:
476 <UL>
477 <LI>Strings which are not entire sentences, see the maintainer guidelines
479 in section <A HREF="gettext_3.html#SEC15">3.2 Preparing Translatable Strings</A>.
480 <LI>Strings which use unclear terms or require additional context to be
482 understood.
483 <LI>Strings which make invalid assumptions about notation of date, time or
485 money.
486 <LI>Pluralisation problems.
488 <LI>Incorrect English spelling.
490 <LI>Incorrect formatting.
492 </UL>
494 It can be your email address, or a mailing list address where translators
495 can write to without being subscribed, or the URL of a web page through
496 which the translators can contact you.
498 The default value is empty, which means that translators will be clueless!
499 Don't forget to specify this option.
501 <DT><SAMP>`-m [<VAR>string</VAR>]&acute;</SAMP>
502 <DD>
503 <DT><SAMP>`--msgstr-prefix[=<VAR>string</VAR>]&acute;</SAMP>
504 <DD>
505 <A NAME="IDX251"></A>
506 <A NAME="IDX252"></A>
507 Use <VAR>string</VAR> (or "" if not specified) as prefix for msgstr entries.
509 <DT><SAMP>`-M [<VAR>string</VAR>]&acute;</SAMP>
510 <DD>
511 <DT><SAMP>`--msgstr-suffix[=<VAR>string</VAR>]&acute;</SAMP>
512 <DD>
513 <A NAME="IDX253"></A>
514 <A NAME="IDX254"></A>
515 Use <VAR>string</VAR> (or "" if not specified) as suffix for msgstr entries.
517 </DL>
521 <H3><A NAME="SEC31" HREF="gettext_toc.html#TOC31">4.1.8 Informative output</A></H3>
523 <DL COMPACT>
525 <DT><SAMP>`-h&acute;</SAMP>
526 <DD>
527 <DT><SAMP>`--help&acute;</SAMP>
528 <DD>
529 <A NAME="IDX255"></A>
530 <A NAME="IDX256"></A>
531 Display this help and exit.
533 <DT><SAMP>`-V&acute;</SAMP>
534 <DD>
535 <DT><SAMP>`--version&acute;</SAMP>
536 <DD>
537 <A NAME="IDX257"></A>
538 <A NAME="IDX258"></A>
539 Output version information and exit.
541 </DL>
543 <P><HR><P>
544 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_22.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
545 </BODY>
546 </HTML>