Imported Upstream version 0.19.8.1
[platform/upstream/gettext.git] / gettext-tools / doc / gettext_9.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 - 9  Manipulating PO Files</TITLE>
8 </HEAD>
9 <BODY>
10 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_8.html">previous</A>, <A HREF="gettext_10.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="SEC79" HREF="gettext_toc.html#TOC79">9  Manipulating PO Files</A></H1>
15 <P>
16 <A NAME="IDX546"></A>
17
18 </P>
19 <P>
20 Sometimes it is necessary to manipulate PO files in a way that is better
21 performed automatically than by hand.  GNU <CODE>gettext</CODE> includes a
22 complete set of tools for this purpose.
23
24 </P>
25 <P>
26 <A NAME="IDX547"></A>
27 When merging two packages into a single package, the resulting POT file
28 will be the concatenation of the two packages' POT files.  Thus the
29 maintainer must concatenate the two existing package translations into
30 a single translation catalog, for each language.  This is best performed
31 using <SAMP>&lsquo;msgcat&rsquo;</SAMP>.  It is then the translators' duty to deal with any
32 possible conflicts that arose during the merge.
33
34 </P>
35 <P>
36 <A NAME="IDX548"></A>
37 When a translator takes over the translation job from another translator,
38 but she uses a different character encoding in her locale, she will
39 convert the catalog to her character encoding.  This is best done through
40 the <SAMP>&lsquo;msgconv&rsquo;</SAMP> program.
41
42 </P>
43 <P>
44 When a maintainer takes a source file with tagged messages from another
45 package, he should also take the existing translations for this source
46 file (and not let the translators do the same job twice).  One way to do
47 this is through <SAMP>&lsquo;msggrep&rsquo;</SAMP>, another is to create a POT file for
48 that source file and use <SAMP>&lsquo;msgmerge&rsquo;</SAMP>.
49
50 </P>
51 <P>
52 <A NAME="IDX549"></A>
53 <A NAME="IDX550"></A>
54 When a translator wants to adjust some translation catalog for a special
55 dialect or orthography -- for example, German as written in Switzerland
56 versus German as written in Germany -- she needs to apply some text
57 processing to every message in the catalog.  The tool for doing this is
58 <SAMP>&lsquo;msgfilter&rsquo;</SAMP>.
59
60 </P>
61 <P>
62 Another use of <CODE>msgfilter</CODE> is to produce approximately the POT file for
63 which a given PO file was made.  This can be done through a filter command
64 like <SAMP>&lsquo;msgfilter sed -e d | sed -e '/^# /d'&rsquo;</SAMP>.  Note that the original
65 POT file may have had different comments and different plural message counts,
66 that's why it's better to use the original POT file if available.
67
68 </P>
69 <P>
70 <A NAME="IDX551"></A>
71 When a translator wants to check her translations, for example according
72 to orthography rules or using a non-interactive spell checker, she can do
73 so using the <SAMP>&lsquo;msgexec&rsquo;</SAMP> program.
74
75 </P>
76 <P>
77 <A NAME="IDX552"></A>
78 When third party tools create PO or POT files, sometimes duplicates cannot
79 be avoided.  But the GNU <CODE>gettext</CODE> tools give an error when they
80 encounter duplicate msgids in the same file and in the same domain.
81 To merge duplicates, the <SAMP>&lsquo;msguniq&rsquo;</SAMP> program can be used.
82
83 </P>
84 <P>
85 <SAMP>&lsquo;msgcomm&rsquo;</SAMP> is a more general tool for keeping or throwing away
86 duplicates, occurring in different files.
87
88 </P>
89 <P>
90 <SAMP>&lsquo;msgcmp&rsquo;</SAMP> can be used to check whether a translation catalog is
91 completely translated.
92
93 </P>
94 <P>
95 <A NAME="IDX553"></A>
96 <SAMP>&lsquo;msgattrib&rsquo;</SAMP> can be used to select and extract only the fuzzy
97 or untranslated messages of a translation catalog.
98
99 </P>
100 <P>
101 <SAMP>&lsquo;msgen&rsquo;</SAMP> is useful as a first step for preparing English translation
102 catalogs.  It copies each message's msgid to its msgstr.
103
104 </P>
105 <P>
106 Finally, for those applications where all these various programs are not
107 sufficient, a library <SAMP>&lsquo;libgettextpo&rsquo;</SAMP> is provided that can be used to
108 write other specialized programs that process PO files.
109
110 </P>
111
112
113
114 <H2><A NAME="SEC80" HREF="gettext_toc.html#TOC80">9.1  Invoking the <CODE>msgcat</CODE> Program</A></H2>
115
116 <P>
117 <A NAME="IDX554"></A>
118 <A NAME="IDX555"></A>
119
120 <PRE>
121 msgcat [<VAR>option</VAR>] [<VAR>inputfile</VAR>]...
122 </PRE>
123
124 <P>
125 <A NAME="IDX556"></A>
126 <A NAME="IDX557"></A>
127 The <CODE>msgcat</CODE> program concatenates and merges the specified PO files.
128 It finds messages which are common to two or more of the specified PO files.
129 By using the <CODE>--more-than</CODE> option, greater commonality may be requested
130 before messages are printed.  Conversely, the <CODE>--less-than</CODE> option may be
131 used to specify less commonality before messages are printed (i.e.
132 <SAMP>&lsquo;--less-than=2&rsquo;</SAMP> will only print the unique messages).  Translations,
133 comments, extracted comments, and file positions will be cumulated, except that
134 if <CODE>--use-first</CODE> is specified, they will be taken from the first PO file
135 to define them.
136
137 </P>
138
139
140 <H3><A NAME="SEC81" HREF="gettext_toc.html#TOC81">9.1.1  Input file location</A></H3>
141
142 <DL COMPACT>
143
144 <DT><SAMP>&lsquo;<VAR>inputfile</VAR> ...&rsquo;</SAMP>
145 <DD>
146 Input files.
147
148 <DT><SAMP>&lsquo;-f <VAR>file</VAR>&rsquo;</SAMP>
149 <DD>
150 <DT><SAMP>&lsquo;--files-from=<VAR>file</VAR>&rsquo;</SAMP>
151 <DD>
152 <A NAME="IDX558"></A>
153 <A NAME="IDX559"></A>
154 Read the names of the input files from <VAR>file</VAR> instead of getting
155 them from the command line.
156
157 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
158 <DD>
159 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
160 <DD>
161 <A NAME="IDX560"></A>
162 <A NAME="IDX561"></A>
163 Add <VAR>directory</VAR> to the list of directories.  Source files are
164 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
165 file will be written relative to the current directory, though.
166
167 </DL>
168
169 <P>
170 If <VAR>inputfile</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
171
172 </P>
173
174
175 <H3><A NAME="SEC82" HREF="gettext_toc.html#TOC82">9.1.2  Output file location</A></H3>
176
177 <DL COMPACT>
178
179 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
180 <DD>
181 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
182 <DD>
183 <A NAME="IDX562"></A>
184 <A NAME="IDX563"></A>
185 Write output to specified file.
186
187 </DL>
188
189 <P>
190 <A NAME="IDX564"></A>
191 The results are written to standard output if no output file is specified
192 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
193
194 </P>
195
196
197 <H3><A NAME="SEC83" HREF="gettext_toc.html#TOC83">9.1.3  Message selection</A></H3>
198
199 <DL COMPACT>
200
201 <DT><SAMP>&lsquo;-&#60; <VAR>number</VAR>&rsquo;</SAMP>
202 <DD>
203 <DT><SAMP>&lsquo;--less-than=<VAR>number</VAR>&rsquo;</SAMP>
204 <DD>
205 <A NAME="IDX565"></A>
206 <A NAME="IDX566"></A>
207 Print messages with less than <VAR>number</VAR> definitions, defaults to infinite
208 if not set.
209
210 <DT><SAMP>&lsquo;-&#62; <VAR>number</VAR>&rsquo;</SAMP>
211 <DD>
212 <DT><SAMP>&lsquo;--more-than=<VAR>number</VAR>&rsquo;</SAMP>
213 <DD>
214 <A NAME="IDX567"></A>
215 <A NAME="IDX568"></A>
216 Print messages with more than <VAR>number</VAR> definitions, defaults to 0 if not
217 set.
218
219 <DT><SAMP>&lsquo;-u&rsquo;</SAMP>
220 <DD>
221 <DT><SAMP>&lsquo;--unique&rsquo;</SAMP>
222 <DD>
223 <A NAME="IDX569"></A>
224 <A NAME="IDX570"></A>
225 Shorthand for <SAMP>&lsquo;--less-than=2&rsquo;</SAMP>.  Requests that only unique messages be
226 printed.
227
228 </DL>
229
230
231
232 <H3><A NAME="SEC84" HREF="gettext_toc.html#TOC84">9.1.4  Input file syntax</A></H3>
233
234 <DL COMPACT>
235
236 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
237 <DD>
238 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
239 <DD>
240 <A NAME="IDX571"></A>
241 <A NAME="IDX572"></A>
242 Assume the input files are Java ResourceBundles in Java <CODE>.properties</CODE>
243 syntax, not in PO file syntax.
244
245 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
246 <DD>
247 <A NAME="IDX573"></A>
248 Assume the input files are NeXTstep/GNUstep localized resource files in
249 <CODE>.strings</CODE> syntax, not in PO file syntax.
250
251 </DL>
252
253
254
255 <H3><A NAME="SEC85" HREF="gettext_toc.html#TOC85">9.1.5  Output details</A></H3>
256
257 <DL COMPACT>
258
259 <DT><SAMP>&lsquo;-t&rsquo;</SAMP>
260 <DD>
261 <DT><SAMP>&lsquo;--to-code=<VAR>name</VAR>&rsquo;</SAMP>
262 <DD>
263 <A NAME="IDX574"></A>
264 <A NAME="IDX575"></A>
265 Specify encoding for output.
266
267 <DT><SAMP>&lsquo;--use-first&rsquo;</SAMP>
268 <DD>
269 <A NAME="IDX576"></A>
270 Use first available translation for each message.  Don't merge several
271 translations into one.
272
273 <DT><SAMP>&lsquo;--lang=<VAR>catalogname</VAR>&rsquo;</SAMP>
274 <DD>
275 <A NAME="IDX577"></A>
276 Specify the <SAMP>&lsquo;Language&rsquo;</SAMP> field to be used in the header entry.  See
277 section <A HREF="gettext_6.html#SEC44">6.2  Filling in the Header Entry</A> for the meaning of this field.  Note: The
278 <SAMP>&lsquo;Language-Team&rsquo;</SAMP> and <SAMP>&lsquo;Plural-Forms&rsquo;</SAMP> fields are left unchanged.
279
280 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
281 <DD>
282 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
283 <DD>
284 <A NAME="IDX578"></A>
285 Specify whether or when to use colors and other text attributes.
286 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
287
288 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
289 <DD>
290 <A NAME="IDX579"></A>
291 Specify the CSS style rule file to use for <CODE>--color</CODE>.
292 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
293
294 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
295 <DD>
296 <A NAME="IDX580"></A>
297 Always write an output file even if it contains no message.
298
299 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
300 <DD>
301 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
302 <DD>
303 <A NAME="IDX581"></A>
304 <A NAME="IDX582"></A>
305 Write the .po file using indented style.
306
307 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
308 <DD>
309 <A NAME="IDX583"></A>
310 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
311
312 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
313 <DD>
314 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
315 <DD>
316 <A NAME="IDX584"></A>
317 <A NAME="IDX585"></A>
318 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
319
320 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
321 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
322 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
323 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
324 suppresses the lines (same as <CODE>--no-location</CODE>).
325
326 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
327 <DD>
328 <A NAME="IDX586"></A>
329 Write out a strict Uniforum conforming PO file.  Note that this
330 Uniforum format should be avoided because it doesn't support the
331 GNU extensions.
332
333 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
334 <DD>
335 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
336 <DD>
337 <A NAME="IDX587"></A>
338 <A NAME="IDX588"></A>
339 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
340 that this file format doesn't support plural forms and silently drops
341 obsolete messages.
342
343 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
344 <DD>
345 <A NAME="IDX589"></A>
346 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
347 Note that this file format doesn't support plural forms.
348
349 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
350 <DD>
351 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
352 <DD>
353 <A NAME="IDX590"></A>
354 <A NAME="IDX591"></A>
355 Set the output page width.  Long strings in the output files will be
356 split across multiple lines in order to ensure that each line's width
357 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
358
359 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
360 <DD>
361 <A NAME="IDX592"></A>
362 Do not break long message lines.  Message lines whose width exceeds the
363 output page width will not be split into several lines.  Only file reference
364 lines which are wider than the output page width will be split.
365
366 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
367 <DD>
368 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
369 <DD>
370 <A NAME="IDX593"></A>
371 <A NAME="IDX594"></A>
372 <A NAME="IDX595"></A>
373 Generate sorted output.  Note that using this option makes it much harder
374 for the translator to understand each message's context.
375
376 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
377 <DD>
378 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
379 <DD>
380 <A NAME="IDX596"></A>
381 <A NAME="IDX597"></A>
382 Sort output by file location.
383
384 </DL>
385
386
387
388 <H3><A NAME="SEC86" HREF="gettext_toc.html#TOC86">9.1.6  Informative output</A></H3>
389
390 <DL COMPACT>
391
392 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
393 <DD>
394 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
395 <DD>
396 <A NAME="IDX598"></A>
397 <A NAME="IDX599"></A>
398 Display this help and exit.
399
400 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
401 <DD>
402 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
403 <DD>
404 <A NAME="IDX600"></A>
405 <A NAME="IDX601"></A>
406 Output version information and exit.
407
408 </DL>
409
410
411
412 <H2><A NAME="SEC87" HREF="gettext_toc.html#TOC87">9.2  Invoking the <CODE>msgconv</CODE> Program</A></H2>
413
414 <P>
415 <A NAME="IDX602"></A>
416 <A NAME="IDX603"></A>
417
418 <PRE>
419 msgconv [<VAR>option</VAR>] [<VAR>inputfile</VAR>]
420 </PRE>
421
422 <P>
423 <A NAME="IDX604"></A>
424 The <CODE>msgconv</CODE> program converts a translation catalog to a different
425 character encoding.
426
427 </P>
428
429
430 <H3><A NAME="SEC88" HREF="gettext_toc.html#TOC88">9.2.1  Input file location</A></H3>
431
432 <DL COMPACT>
433
434 <DT><SAMP>&lsquo;<VAR>inputfile</VAR>&rsquo;</SAMP>
435 <DD>
436 Input PO file.
437
438 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
439 <DD>
440 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
441 <DD>
442 <A NAME="IDX605"></A>
443 <A NAME="IDX606"></A>
444 Add <VAR>directory</VAR> to the list of directories.  Source files are
445 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
446 file will be written relative to the current directory, though.
447
448 </DL>
449
450 <P>
451 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
452
453 </P>
454
455
456 <H3><A NAME="SEC89" HREF="gettext_toc.html#TOC89">9.2.2  Output file location</A></H3>
457
458 <DL COMPACT>
459
460 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
461 <DD>
462 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
463 <DD>
464 <A NAME="IDX607"></A>
465 <A NAME="IDX608"></A>
466 Write output to specified file.
467
468 </DL>
469
470 <P>
471 The results are written to standard output if no output file is specified
472 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
473
474 </P>
475
476
477 <H3><A NAME="SEC90" HREF="gettext_toc.html#TOC90">9.2.3  Conversion target</A></H3>
478
479 <DL COMPACT>
480
481 <DT><SAMP>&lsquo;-t&rsquo;</SAMP>
482 <DD>
483 <DT><SAMP>&lsquo;--to-code=<VAR>name</VAR>&rsquo;</SAMP>
484 <DD>
485 <A NAME="IDX609"></A>
486 <A NAME="IDX610"></A>
487 Specify encoding for output.
488
489 </DL>
490
491 <P>
492 The default encoding is the current locale's encoding.
493
494 </P>
495
496
497 <H3><A NAME="SEC91" HREF="gettext_toc.html#TOC91">9.2.4  Input file syntax</A></H3>
498
499 <DL COMPACT>
500
501 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
502 <DD>
503 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
504 <DD>
505 <A NAME="IDX611"></A>
506 <A NAME="IDX612"></A>
507 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
508 syntax, not in PO file syntax.
509
510 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
511 <DD>
512 <A NAME="IDX613"></A>
513 Assume the input file is a NeXTstep/GNUstep localized resource file in
514 <CODE>.strings</CODE> syntax, not in PO file syntax.
515
516 </DL>
517
518
519
520 <H3><A NAME="SEC92" HREF="gettext_toc.html#TOC92">9.2.5  Output details</A></H3>
521
522 <DL COMPACT>
523
524 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
525 <DD>
526 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
527 <DD>
528 <A NAME="IDX614"></A>
529 Specify whether or when to use colors and other text attributes.
530 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
531
532 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
533 <DD>
534 <A NAME="IDX615"></A>
535 Specify the CSS style rule file to use for <CODE>--color</CODE>.
536 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
537
538 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
539 <DD>
540 <A NAME="IDX616"></A>
541 Always write an output file even if it contains no message.
542
543 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
544 <DD>
545 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
546 <DD>
547 <A NAME="IDX617"></A>
548 <A NAME="IDX618"></A>
549 Write the .po file using indented style.
550
551 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
552 <DD>
553 <A NAME="IDX619"></A>
554 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
555
556 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
557 <DD>
558 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
559 <DD>
560 <A NAME="IDX620"></A>
561 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
562
563 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
564 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
565 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
566 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
567 suppresses the lines (same as <CODE>--no-location</CODE>).
568
569 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
570 <DD>
571 <A NAME="IDX621"></A>
572 Write out a strict Uniforum conforming PO file.  Note that this
573 Uniforum format should be avoided because it doesn't support the
574 GNU extensions.
575
576 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
577 <DD>
578 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
579 <DD>
580 <A NAME="IDX622"></A>
581 <A NAME="IDX623"></A>
582 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
583 that this file format doesn't support plural forms and silently drops
584 obsolete messages.
585
586 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
587 <DD>
588 <A NAME="IDX624"></A>
589 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
590 Note that this file format doesn't support plural forms.
591
592 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
593 <DD>
594 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
595 <DD>
596 <A NAME="IDX625"></A>
597 <A NAME="IDX626"></A>
598 Set the output page width.  Long strings in the output files will be
599 split across multiple lines in order to ensure that each line's width
600 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
601
602 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
603 <DD>
604 <A NAME="IDX627"></A>
605 Do not break long message lines.  Message lines whose width exceeds the
606 output page width will not be split into several lines.  Only file reference
607 lines which are wider than the output page width will be split.
608
609 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
610 <DD>
611 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
612 <DD>
613 <A NAME="IDX628"></A>
614 <A NAME="IDX629"></A>
615 Generate sorted output.  Note that using this option makes it much harder
616 for the translator to understand each message's context.
617
618 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
619 <DD>
620 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
621 <DD>
622 <A NAME="IDX630"></A>
623 <A NAME="IDX631"></A>
624 Sort output by file location.
625
626 </DL>
627
628
629
630 <H3><A NAME="SEC93" HREF="gettext_toc.html#TOC93">9.2.6  Informative output</A></H3>
631
632 <DL COMPACT>
633
634 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
635 <DD>
636 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
637 <DD>
638 <A NAME="IDX632"></A>
639 <A NAME="IDX633"></A>
640 Display this help and exit.
641
642 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
643 <DD>
644 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
645 <DD>
646 <A NAME="IDX634"></A>
647 <A NAME="IDX635"></A>
648 Output version information and exit.
649
650 </DL>
651
652
653
654 <H2><A NAME="SEC94" HREF="gettext_toc.html#TOC94">9.3  Invoking the <CODE>msggrep</CODE> Program</A></H2>
655
656 <P>
657 <A NAME="IDX636"></A>
658 <A NAME="IDX637"></A>
659
660 <PRE>
661 msggrep [<VAR>option</VAR>] [<VAR>inputfile</VAR>]
662 </PRE>
663
664 <P>
665 <A NAME="IDX638"></A>
666 The <CODE>msggrep</CODE> program extracts all messages of a translation catalog
667 that match a given pattern or belong to some given source files.
668
669 </P>
670
671
672 <H3><A NAME="SEC95" HREF="gettext_toc.html#TOC95">9.3.1  Input file location</A></H3>
673
674 <DL COMPACT>
675
676 <DT><SAMP>&lsquo;<VAR>inputfile</VAR>&rsquo;</SAMP>
677 <DD>
678 Input PO file.
679
680 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
681 <DD>
682 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
683 <DD>
684 <A NAME="IDX639"></A>
685 <A NAME="IDX640"></A>
686 Add <VAR>directory</VAR> to the list of directories.  Source files are
687 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
688 file will be written relative to the current directory, though.
689
690 </DL>
691
692 <P>
693 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
694
695 </P>
696
697
698 <H3><A NAME="SEC96" HREF="gettext_toc.html#TOC96">9.3.2  Output file location</A></H3>
699
700 <DL COMPACT>
701
702 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
703 <DD>
704 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
705 <DD>
706 <A NAME="IDX641"></A>
707 <A NAME="IDX642"></A>
708 Write output to specified file.
709
710 </DL>
711
712 <P>
713 The results are written to standard output if no output file is specified
714 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
715
716 </P>
717
718
719 <H3><A NAME="SEC97" HREF="gettext_toc.html#TOC97">9.3.3  Message selection</A></H3>
720
721
722 <PRE>
723   [-N <VAR>sourcefile</VAR>]... [-M <VAR>domainname</VAR>]...
724   [-J <VAR>msgctxt-pattern</VAR>] [-K <VAR>msgid-pattern</VAR>] [-T <VAR>msgstr-pattern</VAR>]
725   [-C <VAR>comment-pattern</VAR>]
726 </PRE>
727
728 <P>
729 A message is selected if
730
731 <UL>
732 <LI>it comes from one of the specified source files,
733
734 <LI>or if it comes from one of the specified domains,
735
736 <LI>or if <SAMP>&lsquo;-J&rsquo;</SAMP> is given and its context (msgctxt) matches
737
738 <VAR>msgctxt-pattern</VAR>,
739 <LI>or if <SAMP>&lsquo;-K&rsquo;</SAMP> is given and its key (msgid or msgid_plural) matches
740
741 <VAR>msgid-pattern</VAR>,
742 <LI>or if <SAMP>&lsquo;-T&rsquo;</SAMP> is given and its translation (msgstr) matches
743
744 <VAR>msgstr-pattern</VAR>,
745 <LI>or if <SAMP>&lsquo;-C&rsquo;</SAMP> is given and the translator's comment matches
746
747 <VAR>comment-pattern</VAR>.
748 </UL>
749
750 <P>
751 When more than one selection criterion is specified, the set of selected
752 messages is the union of the selected messages of each criterion.
753
754 </P>
755 <P>
756 <VAR>msgctxt-pattern</VAR> or <VAR>msgid-pattern</VAR> or <VAR>msgstr-pattern</VAR> syntax:
757
758 <PRE>
759   [-E | -F] [-e <VAR>pattern</VAR> | -f <VAR>file</VAR>]...
760 </PRE>
761
762 <P>
763 <VAR>pattern</VAR>s are basic regular expressions by default, or extended regular
764 expressions if -E is given, or fixed strings if -F is given.
765
766 </P>
767 <DL COMPACT>
768
769 <DT><SAMP>&lsquo;-N <VAR>sourcefile</VAR>&rsquo;</SAMP>
770 <DD>
771 <DT><SAMP>&lsquo;--location=<VAR>sourcefile</VAR>&rsquo;</SAMP>
772 <DD>
773 <A NAME="IDX643"></A>
774 <A NAME="IDX644"></A>
775 Select messages extracted from <VAR>sourcefile</VAR>.  <VAR>sourcefile</VAR> can be
776 either a literal file name or a wildcard pattern.
777
778 <DT><SAMP>&lsquo;-M <VAR>domainname</VAR>&rsquo;</SAMP>
779 <DD>
780 <DT><SAMP>&lsquo;--domain=<VAR>domainname</VAR>&rsquo;</SAMP>
781 <DD>
782 <A NAME="IDX645"></A>
783 <A NAME="IDX646"></A>
784 Select messages belonging to domain <VAR>domainname</VAR>.
785
786 <DT><SAMP>&lsquo;-J&rsquo;</SAMP>
787 <DD>
788 <DT><SAMP>&lsquo;--msgctxt&rsquo;</SAMP>
789 <DD>
790 <A NAME="IDX647"></A>
791 <A NAME="IDX648"></A>
792 Start of patterns for the msgctxt.
793
794 <DT><SAMP>&lsquo;-K&rsquo;</SAMP>
795 <DD>
796 <DT><SAMP>&lsquo;--msgid&rsquo;</SAMP>
797 <DD>
798 <A NAME="IDX649"></A>
799 <A NAME="IDX650"></A>
800 Start of patterns for the msgid.
801
802 <DT><SAMP>&lsquo;-T&rsquo;</SAMP>
803 <DD>
804 <DT><SAMP>&lsquo;--msgstr&rsquo;</SAMP>
805 <DD>
806 <A NAME="IDX651"></A>
807 <A NAME="IDX652"></A>
808 Start of patterns for the msgstr.
809
810 <DT><SAMP>&lsquo;-C&rsquo;</SAMP>
811 <DD>
812 <DT><SAMP>&lsquo;--comment&rsquo;</SAMP>
813 <DD>
814 <A NAME="IDX653"></A>
815 <A NAME="IDX654"></A>
816 Start of patterns for the translator's comment.
817
818 <DT><SAMP>&lsquo;-X&rsquo;</SAMP>
819 <DD>
820 <DT><SAMP>&lsquo;--extracted-comment&rsquo;</SAMP>
821 <DD>
822 <A NAME="IDX655"></A>
823 <A NAME="IDX656"></A>
824 Start of patterns for the extracted comments.
825
826 <DT><SAMP>&lsquo;-E&rsquo;</SAMP>
827 <DD>
828 <DT><SAMP>&lsquo;--extended-regexp&rsquo;</SAMP>
829 <DD>
830 <A NAME="IDX657"></A>
831 <A NAME="IDX658"></A>
832 Specify that <VAR>pattern</VAR> is an extended regular expression.
833
834 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
835 <DD>
836 <DT><SAMP>&lsquo;--fixed-strings&rsquo;</SAMP>
837 <DD>
838 <A NAME="IDX659"></A>
839 <A NAME="IDX660"></A>
840 Specify that <VAR>pattern</VAR> is a set of newline-separated strings.
841
842 <DT><SAMP>&lsquo;-e <VAR>pattern</VAR>&rsquo;</SAMP>
843 <DD>
844 <DT><SAMP>&lsquo;--regexp=<VAR>pattern</VAR>&rsquo;</SAMP>
845 <DD>
846 <A NAME="IDX661"></A>
847 <A NAME="IDX662"></A>
848 Use <VAR>pattern</VAR> as a regular expression.
849
850 <DT><SAMP>&lsquo;-f <VAR>file</VAR>&rsquo;</SAMP>
851 <DD>
852 <DT><SAMP>&lsquo;--file=<VAR>file</VAR>&rsquo;</SAMP>
853 <DD>
854 <A NAME="IDX663"></A>
855 <A NAME="IDX664"></A>
856 Obtain <VAR>pattern</VAR> from <VAR>file</VAR>.
857
858 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
859 <DD>
860 <DT><SAMP>&lsquo;--ignore-case&rsquo;</SAMP>
861 <DD>
862 <A NAME="IDX665"></A>
863 <A NAME="IDX666"></A>
864 Ignore case distinctions.
865
866 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
867 <DD>
868 <DT><SAMP>&lsquo;--invert-match&rsquo;</SAMP>
869 <DD>
870 <A NAME="IDX667"></A>
871 <A NAME="IDX668"></A>
872 Output only the messages that do not match any selection criterion, instead
873 of the messages that match a selection criterion.
874
875 </DL>
876
877
878
879 <H3><A NAME="SEC98" HREF="gettext_toc.html#TOC98">9.3.4  Input file syntax</A></H3>
880
881 <DL COMPACT>
882
883 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
884 <DD>
885 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
886 <DD>
887 <A NAME="IDX669"></A>
888 <A NAME="IDX670"></A>
889 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
890 syntax, not in PO file syntax.
891
892 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
893 <DD>
894 <A NAME="IDX671"></A>
895 Assume the input file is a NeXTstep/GNUstep localized resource file in
896 <CODE>.strings</CODE> syntax, not in PO file syntax.
897
898 </DL>
899
900
901
902 <H3><A NAME="SEC99" HREF="gettext_toc.html#TOC99">9.3.5  Output details</A></H3>
903
904 <DL COMPACT>
905
906 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
907 <DD>
908 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
909 <DD>
910 <A NAME="IDX672"></A>
911 Specify whether or when to use colors and other text attributes.
912 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
913
914 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
915 <DD>
916 <A NAME="IDX673"></A>
917 Specify the CSS style rule file to use for <CODE>--color</CODE>.
918 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
919
920 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
921 <DD>
922 <A NAME="IDX674"></A>
923 Always write an output file even if it contains no message.
924
925 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
926 <DD>
927 <A NAME="IDX675"></A>
928 Write the .po file using indented style.
929
930 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
931 <DD>
932 <A NAME="IDX676"></A>
933 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
934
935 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
936 <DD>
937 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
938 <DD>
939 <A NAME="IDX677"></A>
940 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
941
942 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
943 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
944 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
945 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
946 suppresses the lines (same as <CODE>--no-location</CODE>).
947
948 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
949 <DD>
950 <A NAME="IDX678"></A>
951 Write out a strict Uniforum conforming PO file.  Note that this
952 Uniforum format should be avoided because it doesn't support the
953 GNU extensions.
954
955 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
956 <DD>
957 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
958 <DD>
959 <A NAME="IDX679"></A>
960 <A NAME="IDX680"></A>
961 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
962 that this file format doesn't support plural forms and silently drops
963 obsolete messages.
964
965 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
966 <DD>
967 <A NAME="IDX681"></A>
968 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
969 Note that this file format doesn't support plural forms.
970
971 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
972 <DD>
973 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
974 <DD>
975 <A NAME="IDX682"></A>
976 <A NAME="IDX683"></A>
977 Set the output page width.  Long strings in the output files will be
978 split across multiple lines in order to ensure that each line's width
979 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
980
981 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
982 <DD>
983 <A NAME="IDX684"></A>
984 Do not break long message lines.  Message lines whose width exceeds the
985 output page width will not be split into several lines.  Only file reference
986 lines which are wider than the output page width will be split.
987
988 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
989 <DD>
990 <A NAME="IDX685"></A>
991 Generate sorted output.  Note that using this option makes it much harder
992 for the translator to understand each message's context.
993
994 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
995 <DD>
996 <A NAME="IDX686"></A>
997 Sort output by file location.
998
999 </DL>
1000
1001
1002
1003 <H3><A NAME="SEC100" HREF="gettext_toc.html#TOC100">9.3.6  Informative output</A></H3>
1004
1005 <DL COMPACT>
1006
1007 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
1008 <DD>
1009 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
1010 <DD>
1011 <A NAME="IDX687"></A>
1012 <A NAME="IDX688"></A>
1013 Display this help and exit.
1014
1015 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
1016 <DD>
1017 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
1018 <DD>
1019 <A NAME="IDX689"></A>
1020 <A NAME="IDX690"></A>
1021 Output version information and exit.
1022
1023 </DL>
1024
1025
1026
1027 <H3><A NAME="SEC101" HREF="gettext_toc.html#TOC101">9.3.7  Examples</A></H3>
1028
1029 <P>
1030 To extract the messages that come from the source files
1031 <CODE>gnulib-lib/error.c</CODE> and <CODE>gnulib-lib/getopt.c</CODE>:
1032
1033 </P>
1034
1035 <PRE>
1036 msggrep -N gnulib-lib/error.c -N gnulib-lib/getopt.c input.po
1037 </PRE>
1038
1039 <P>
1040 To extract the messages that contain the string “Please specify” in the
1041 original string:
1042
1043 </P>
1044
1045 <PRE>
1046 msggrep --msgid -F -e 'Please specify' input.po
1047 </PRE>
1048
1049 <P>
1050 To extract the messages that have a context specifier of either “Menu&#62;File”
1051 or “Menu&#62;Edit” or a submenu of them:
1052
1053 </P>
1054
1055 <PRE>
1056 msggrep --msgctxt -E -e '^Menu&#62;(File|Edit)' input.po
1057 </PRE>
1058
1059 <P>
1060 To extract the messages whose translation contains one of the strings in the
1061 file <CODE>wordlist.txt</CODE>:
1062
1063 </P>
1064
1065 <PRE>
1066 msggrep --msgstr -F -f wordlist.txt input.po
1067 </PRE>
1068
1069
1070
1071 <H2><A NAME="SEC102" HREF="gettext_toc.html#TOC102">9.4  Invoking the <CODE>msgfilter</CODE> Program</A></H2>
1072
1073 <P>
1074 <A NAME="IDX691"></A>
1075 <A NAME="IDX692"></A>
1076
1077 <PRE>
1078 msgfilter [<VAR>option</VAR>] <VAR>filter</VAR> [<VAR>filter-option</VAR>]
1079 </PRE>
1080
1081 <P>
1082 <A NAME="IDX693"></A>
1083 The <CODE>msgfilter</CODE> program applies a filter to all translations of a
1084 translation catalog.
1085
1086 </P>
1087 <P>
1088 <A NAME="IDX694"></A>
1089 <A NAME="IDX695"></A>
1090 <A NAME="IDX696"></A>
1091 <A NAME="IDX697"></A>
1092 <A NAME="IDX698"></A>
1093 <A NAME="IDX699"></A>
1094 <A NAME="IDX700"></A>
1095 <A NAME="IDX701"></A>
1096 During each <VAR>filter</VAR> invocation, the environment variable
1097 <CODE>MSGFILTER_MSGID</CODE> is bound to the message's msgid, and the environment
1098 variable <CODE>MSGFILTER_LOCATION</CODE> is bound to the location in the PO file
1099 of the message.  If the message has a context, the environment variable
1100 <CODE>MSGFILTER_MSGCTXT</CODE> is bound to the message's msgctxt, otherwise it is
1101 unbound.  If the message has a plural form, environment variable
1102 <CODE>MSGFILTER_MSGID_PLURAL</CODE> is bound to the message's msgid_plural and
1103 <CODE>MSGFILTER_PLURAL_FORM</CODE> is bound to the order number of the plural
1104 actually processed (starting with 0), otherwise both are unbound.
1105 If the message has a previous msgid (added by <CODE>msgmerge</CODE>),
1106 environment variable <CODE>MSGFILTER_PREV_MSGCTXT</CODE> is bound to the
1107 message's previous msgctxt, <CODE>MSGFILTER_PREV_MSGID</CODE> is bound to
1108 the previous msgid, and <CODE>MSGFILTER_PREV_MSGID_PLURAL</CODE> is bound to
1109 the previous msgid_plural.
1110
1111 </P>
1112
1113
1114 <H3><A NAME="SEC103" HREF="gettext_toc.html#TOC103">9.4.1  Input file location</A></H3>
1115
1116 <DL COMPACT>
1117
1118 <DT><SAMP>&lsquo;-i <VAR>inputfile</VAR>&rsquo;</SAMP>
1119 <DD>
1120 <DT><SAMP>&lsquo;--input=<VAR>inputfile</VAR>&rsquo;</SAMP>
1121 <DD>
1122 <A NAME="IDX702"></A>
1123 <A NAME="IDX703"></A>
1124 Input PO file.
1125
1126 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
1127 <DD>
1128 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
1129 <DD>
1130 <A NAME="IDX704"></A>
1131 <A NAME="IDX705"></A>
1132 Add <VAR>directory</VAR> to the list of directories.  Source files are
1133 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
1134 file will be written relative to the current directory, though.
1135
1136 </DL>
1137
1138 <P>
1139 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
1140
1141 </P>
1142
1143
1144 <H3><A NAME="SEC104" HREF="gettext_toc.html#TOC104">9.4.2  Output file location</A></H3>
1145
1146 <DL COMPACT>
1147
1148 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
1149 <DD>
1150 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
1151 <DD>
1152 <A NAME="IDX706"></A>
1153 <A NAME="IDX707"></A>
1154 Write output to specified file.
1155
1156 </DL>
1157
1158 <P>
1159 The results are written to standard output if no output file is specified
1160 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
1161
1162 </P>
1163
1164
1165 <H3><A NAME="SEC105" HREF="gettext_toc.html#TOC105">9.4.3  The filter</A></H3>
1166
1167 <P>
1168 The <VAR>filter</VAR> can be any program that reads a translation from standard
1169 input and writes a modified translation to standard output.  A frequently
1170 used filter is <SAMP>&lsquo;sed&rsquo;</SAMP>.  A few particular built-in filters are also
1171 recognized.
1172
1173 </P>
1174 <DL COMPACT>
1175
1176 <DT><SAMP>&lsquo;--newline&rsquo;</SAMP>
1177 <DD>
1178 <A NAME="IDX708"></A>
1179 Add newline at the end of each input line and also strip the ending
1180 newline from the output line.
1181
1182 </DL>
1183
1184 <P>
1185 <A NAME="IDX709"></A>
1186 Note: If the filter is not a built-in filter, you have to care about encodings:
1187 It is your responsibility to ensure that the <VAR>filter</VAR> can cope
1188 with input encoded in the translation catalog's encoding.  If the
1189 <VAR>filter</VAR> wants input in a particular encoding, you can in a first step
1190 convert the translation catalog to that encoding using the <SAMP>&lsquo;msgconv&rsquo;</SAMP>
1191 program, before invoking <SAMP>&lsquo;msgfilter&rsquo;</SAMP>.  If the <VAR>filter</VAR> wants input
1192 in the locale's encoding, but you want to avoid the locale's encoding, then
1193 you can first convert the translation catalog to UTF-8 using the
1194 <SAMP>&lsquo;msgconv&rsquo;</SAMP> program and then make <SAMP>&lsquo;msgfilter&rsquo;</SAMP> work in an UTF-8
1195 locale, by using the <CODE>LC_ALL</CODE> environment variable.
1196
1197 </P>
1198 <P>
1199 <A NAME="IDX710"></A>
1200 Note: Most translations in a translation catalog don't end with a
1201 newline character.  For this reason, unless the <CODE>--newline</CODE>
1202 option is used, it is important that the <VAR>filter</VAR> recognizes its
1203 last input line even if it ends without a newline, and that it doesn't
1204 add an undesired trailing newline at the end.  The <SAMP>&lsquo;sed&rsquo;</SAMP> program on
1205 some platforms is known to ignore the last line of input if it is not
1206 terminated with a newline.  You can use GNU <CODE>sed</CODE> instead; it does
1207 not have this limitation.
1208
1209 </P>
1210
1211
1212 <H3><A NAME="SEC106" HREF="gettext_toc.html#TOC106">9.4.4  Useful <VAR>filter-option</VAR>s when the <VAR>filter</VAR> is <SAMP>&lsquo;sed&rsquo;</SAMP></A></H3>
1213
1214 <DL COMPACT>
1215
1216 <DT><SAMP>&lsquo;-e <VAR>script</VAR>&rsquo;</SAMP>
1217 <DD>
1218 <DT><SAMP>&lsquo;--expression=<VAR>script</VAR>&rsquo;</SAMP>
1219 <DD>
1220 <A NAME="IDX711"></A>
1221 <A NAME="IDX712"></A>
1222 Add <VAR>script</VAR> to the commands to be executed.
1223
1224 <DT><SAMP>&lsquo;-f <VAR>scriptfile</VAR>&rsquo;</SAMP>
1225 <DD>
1226 <DT><SAMP>&lsquo;--file=<VAR>scriptfile</VAR>&rsquo;</SAMP>
1227 <DD>
1228 <A NAME="IDX713"></A>
1229 <A NAME="IDX714"></A>
1230 Add the contents of <VAR>scriptfile</VAR> to the commands to be executed.
1231
1232 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
1233 <DD>
1234 <DT><SAMP>&lsquo;--quiet&rsquo;</SAMP>
1235 <DD>
1236 <DT><SAMP>&lsquo;--silent&rsquo;</SAMP>
1237 <DD>
1238 <A NAME="IDX715"></A>
1239 <A NAME="IDX716"></A>
1240 <A NAME="IDX717"></A>
1241 Suppress automatic printing of pattern space.
1242
1243 </DL>
1244
1245
1246
1247 <H3><A NAME="SEC107" HREF="gettext_toc.html#TOC107">9.4.5  Built-in <VAR>filter</VAR>s</A></H3>
1248
1249 <P>
1250 <A NAME="IDX718"></A>
1251 <A NAME="IDX719"></A>
1252 The filter <SAMP>&lsquo;recode-sr-latin&rsquo;</SAMP> is recognized as a built-in filter.
1253 The command <SAMP>&lsquo;recode-sr-latin&rsquo;</SAMP> converts Serbian text, written in the
1254 Cyrillic script, to the Latin script.
1255 The command <SAMP>&lsquo;msgfilter recode-sr-latin&rsquo;</SAMP> applies this conversion to the
1256 translations of a PO file.  Thus, it can be used to convert an <TT>&lsquo;sr.po&rsquo;</TT>
1257 file to an <TT>&lsquo;sr@latin.po&rsquo;</TT> file.
1258
1259 </P>
1260 <P>
1261 <A NAME="IDX720"></A>
1262 The filter <SAMP>&lsquo;quot&rsquo;</SAMP> is recognized as a built-in filter.
1263 The command <SAMP>&lsquo;msgfilter quot&rsquo;</SAMP> converts any quotations surrounded
1264 by a pair of <SAMP>&lsquo;"&rsquo;</SAMP>, <SAMP>&lsquo;'&rsquo;</SAMP>, and <SAMP>&lsquo;`&rsquo;</SAMP>.
1265
1266 </P>
1267 <P>
1268 <A NAME="IDX721"></A>
1269 The filter <SAMP>&lsquo;boldquot&rsquo;</SAMP> is recognized as a built-in filter.
1270 The command <SAMP>&lsquo;msgfilter boldquot&rsquo;</SAMP> converts any quotations
1271 surrounded by a pair of <SAMP>&lsquo;"&rsquo;</SAMP>, <SAMP>&lsquo;'&rsquo;</SAMP>, and <SAMP>&lsquo;`&rsquo;</SAMP>, also adding the
1272 VT100 escape sequences to the text to decorate it as bold.
1273
1274 </P>
1275 <P>
1276 The use of built-in filters is not sensitive to the current locale's encoding.
1277 Moreover, when used with a built-in filter, <SAMP>&lsquo;msgfilter&rsquo;</SAMP> can automatically
1278 convert the message catalog to the UTF-8 encoding when needed.
1279
1280 </P>
1281
1282
1283 <H3><A NAME="SEC108" HREF="gettext_toc.html#TOC108">9.4.6  Input file syntax</A></H3>
1284
1285 <DL COMPACT>
1286
1287 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
1288 <DD>
1289 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
1290 <DD>
1291 <A NAME="IDX722"></A>
1292 <A NAME="IDX723"></A>
1293 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
1294 syntax, not in PO file syntax.
1295
1296 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
1297 <DD>
1298 <A NAME="IDX724"></A>
1299 Assume the input file is a NeXTstep/GNUstep localized resource file in
1300 <CODE>.strings</CODE> syntax, not in PO file syntax.
1301
1302 </DL>
1303
1304
1305
1306 <H3><A NAME="SEC109" HREF="gettext_toc.html#TOC109">9.4.7  Output details</A></H3>
1307
1308 <DL COMPACT>
1309
1310 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
1311 <DD>
1312 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
1313 <DD>
1314 <A NAME="IDX725"></A>
1315 Specify whether or when to use colors and other text attributes.
1316 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
1317
1318 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
1319 <DD>
1320 <A NAME="IDX726"></A>
1321 Specify the CSS style rule file to use for <CODE>--color</CODE>.
1322 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
1323
1324 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
1325 <DD>
1326 <A NAME="IDX727"></A>
1327 Always write an output file even if it contains no message.
1328
1329 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
1330 <DD>
1331 <A NAME="IDX728"></A>
1332 Write the .po file using indented style.
1333
1334 <DT><SAMP>&lsquo;--keep-header&rsquo;</SAMP>
1335 <DD>
1336 <A NAME="IDX729"></A>
1337 Keep the header entry, i.e. the message with <SAMP>&lsquo;msgid ""&rsquo;</SAMP>, unmodified,
1338 instead of filtering it.  By default, the header entry is subject to
1339 filtering like any other message.
1340
1341 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
1342 <DD>
1343 <A NAME="IDX730"></A>
1344 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
1345
1346 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
1347 <DD>
1348 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
1349 <DD>
1350 <A NAME="IDX731"></A>
1351 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
1352
1353 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
1354 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
1355 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
1356 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
1357 suppresses the lines (same as <CODE>--no-location</CODE>).
1358
1359 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
1360 <DD>
1361 <A NAME="IDX732"></A>
1362 Write out a strict Uniforum conforming PO file.  Note that this
1363 Uniforum format should be avoided because it doesn't support the
1364 GNU extensions.
1365
1366 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
1367 <DD>
1368 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
1369 <DD>
1370 <A NAME="IDX733"></A>
1371 <A NAME="IDX734"></A>
1372 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
1373 that this file format doesn't support plural forms and silently drops
1374 obsolete messages.
1375
1376 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
1377 <DD>
1378 <A NAME="IDX735"></A>
1379 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
1380 Note that this file format doesn't support plural forms.
1381
1382 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
1383 <DD>
1384 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
1385 <DD>
1386 <A NAME="IDX736"></A>
1387 <A NAME="IDX737"></A>
1388 Set the output page width.  Long strings in the output files will be
1389 split across multiple lines in order to ensure that each line's width
1390 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
1391
1392 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
1393 <DD>
1394 <A NAME="IDX738"></A>
1395 Do not break long message lines.  Message lines whose width exceeds the
1396 output page width will not be split into several lines.  Only file reference
1397 lines which are wider than the output page width will be split.
1398
1399 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
1400 <DD>
1401 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
1402 <DD>
1403 <A NAME="IDX739"></A>
1404 <A NAME="IDX740"></A>
1405 Generate sorted output.  Note that using this option makes it much harder
1406 for the translator to understand each message's context.
1407
1408 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
1409 <DD>
1410 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
1411 <DD>
1412 <A NAME="IDX741"></A>
1413 <A NAME="IDX742"></A>
1414 Sort output by file location.
1415
1416 </DL>
1417
1418
1419
1420 <H3><A NAME="SEC110" HREF="gettext_toc.html#TOC110">9.4.8  Informative output</A></H3>
1421
1422 <DL COMPACT>
1423
1424 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
1425 <DD>
1426 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
1427 <DD>
1428 <A NAME="IDX743"></A>
1429 <A NAME="IDX744"></A>
1430 Display this help and exit.
1431
1432 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
1433 <DD>
1434 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
1435 <DD>
1436 <A NAME="IDX745"></A>
1437 <A NAME="IDX746"></A>
1438 Output version information and exit.
1439
1440 </DL>
1441
1442
1443
1444 <H3><A NAME="SEC111" HREF="gettext_toc.html#TOC111">9.4.9  Examples</A></H3>
1445
1446 <P>
1447 To convert German translations to Swiss orthography (in an UTF-8 locale):
1448
1449 </P>
1450
1451 <PRE>
1452 msgconv -t UTF-8 de.po | msgfilter sed -e 's/&szlig;/ss/g'
1453 </PRE>
1454
1455 <P>
1456 To convert Serbian translations in Cyrillic script to Latin script:
1457
1458 </P>
1459
1460 <PRE>
1461 msgfilter recode-sr-latin &#60; sr.po
1462 </PRE>
1463
1464
1465
1466 <H2><A NAME="SEC112" HREF="gettext_toc.html#TOC112">9.5  Invoking the <CODE>msguniq</CODE> Program</A></H2>
1467
1468 <P>
1469 <A NAME="IDX747"></A>
1470 <A NAME="IDX748"></A>
1471
1472 <PRE>
1473 msguniq [<VAR>option</VAR>] [<VAR>inputfile</VAR>]
1474 </PRE>
1475
1476 <P>
1477 <A NAME="IDX749"></A>
1478 <A NAME="IDX750"></A>
1479 The <CODE>msguniq</CODE> program unifies duplicate translations in a translation
1480 catalog.  It finds duplicate translations of the same message ID.  Such
1481 duplicates are invalid input for other programs like <CODE>msgfmt</CODE>,
1482 <CODE>msgmerge</CODE> or <CODE>msgcat</CODE>.  By default, duplicates are merged
1483 together.  When using the <SAMP>&lsquo;--repeated&rsquo;</SAMP> option, only duplicates are
1484 output, and all other messages are discarded.  Comments and extracted
1485 comments will be cumulated, except that if <SAMP>&lsquo;--use-first&rsquo;</SAMP> is
1486 specified, they will be taken from the first translation.  File positions
1487 will be cumulated.  When using the <SAMP>&lsquo;--unique&rsquo;</SAMP> option, duplicates are
1488 discarded.
1489
1490 </P>
1491
1492
1493 <H3><A NAME="SEC113" HREF="gettext_toc.html#TOC113">9.5.1  Input file location</A></H3>
1494
1495 <DL COMPACT>
1496
1497 <DT><SAMP>&lsquo;<VAR>inputfile</VAR>&rsquo;</SAMP>
1498 <DD>
1499 Input PO file.
1500
1501 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
1502 <DD>
1503 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
1504 <DD>
1505 <A NAME="IDX751"></A>
1506 <A NAME="IDX752"></A>
1507 Add <VAR>directory</VAR> to the list of directories.  Source files are
1508 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
1509 file will be written relative to the current directory, though.
1510
1511 </DL>
1512
1513 <P>
1514 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
1515
1516 </P>
1517
1518
1519 <H3><A NAME="SEC114" HREF="gettext_toc.html#TOC114">9.5.2  Output file location</A></H3>
1520
1521 <DL COMPACT>
1522
1523 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
1524 <DD>
1525 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
1526 <DD>
1527 <A NAME="IDX753"></A>
1528 <A NAME="IDX754"></A>
1529 Write output to specified file.
1530
1531 </DL>
1532
1533 <P>
1534 The results are written to standard output if no output file is specified
1535 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
1536
1537 </P>
1538
1539
1540 <H3><A NAME="SEC115" HREF="gettext_toc.html#TOC115">9.5.3  Message selection</A></H3>
1541
1542 <DL COMPACT>
1543
1544 <DT><SAMP>&lsquo;-d&rsquo;</SAMP>
1545 <DD>
1546 <DT><SAMP>&lsquo;--repeated&rsquo;</SAMP>
1547 <DD>
1548 <A NAME="IDX755"></A>
1549 <A NAME="IDX756"></A>
1550 Print only duplicates.
1551
1552 <DT><SAMP>&lsquo;-u&rsquo;</SAMP>
1553 <DD>
1554 <DT><SAMP>&lsquo;--unique&rsquo;</SAMP>
1555 <DD>
1556 <A NAME="IDX757"></A>
1557 <A NAME="IDX758"></A>
1558 Print only unique messages, discard duplicates.
1559
1560 </DL>
1561
1562
1563
1564 <H3><A NAME="SEC116" HREF="gettext_toc.html#TOC116">9.5.4  Input file syntax</A></H3>
1565
1566 <DL COMPACT>
1567
1568 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
1569 <DD>
1570 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
1571 <DD>
1572 <A NAME="IDX759"></A>
1573 <A NAME="IDX760"></A>
1574 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
1575 syntax, not in PO file syntax.
1576
1577 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
1578 <DD>
1579 <A NAME="IDX761"></A>
1580 Assume the input file is a NeXTstep/GNUstep localized resource file in
1581 <CODE>.strings</CODE> syntax, not in PO file syntax.
1582
1583 </DL>
1584
1585
1586
1587 <H3><A NAME="SEC117" HREF="gettext_toc.html#TOC117">9.5.5  Output details</A></H3>
1588
1589 <DL COMPACT>
1590
1591 <DT><SAMP>&lsquo;-t&rsquo;</SAMP>
1592 <DD>
1593 <DT><SAMP>&lsquo;--to-code=<VAR>name</VAR>&rsquo;</SAMP>
1594 <DD>
1595 <A NAME="IDX762"></A>
1596 <A NAME="IDX763"></A>
1597 Specify encoding for output.
1598
1599 <DT><SAMP>&lsquo;--use-first&rsquo;</SAMP>
1600 <DD>
1601 <A NAME="IDX764"></A>
1602 Use first available translation for each message.  Don't merge several
1603 translations into one.
1604
1605 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
1606 <DD>
1607 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
1608 <DD>
1609 <A NAME="IDX765"></A>
1610 Specify whether or when to use colors and other text attributes.
1611 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
1612
1613 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
1614 <DD>
1615 <A NAME="IDX766"></A>
1616 Specify the CSS style rule file to use for <CODE>--color</CODE>.
1617 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
1618
1619 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
1620 <DD>
1621 <A NAME="IDX767"></A>
1622 Always write an output file even if it contains no message.
1623
1624 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
1625 <DD>
1626 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
1627 <DD>
1628 <A NAME="IDX768"></A>
1629 <A NAME="IDX769"></A>
1630 Write the .po file using indented style.
1631
1632 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
1633 <DD>
1634 <A NAME="IDX770"></A>
1635 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
1636
1637 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
1638 <DD>
1639 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
1640 <DD>
1641 <A NAME="IDX771"></A>
1642 <A NAME="IDX772"></A>
1643 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
1644
1645 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
1646 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
1647 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
1648 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
1649 suppresses the lines (same as <CODE>--no-location</CODE>).
1650
1651 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
1652 <DD>
1653 <A NAME="IDX773"></A>
1654 Write out a strict Uniforum conforming PO file.  Note that this
1655 Uniforum format should be avoided because it doesn't support the
1656 GNU extensions.
1657
1658 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
1659 <DD>
1660 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
1661 <DD>
1662 <A NAME="IDX774"></A>
1663 <A NAME="IDX775"></A>
1664 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
1665 that this file format doesn't support plural forms and silently drops
1666 obsolete messages.
1667
1668 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
1669 <DD>
1670 <A NAME="IDX776"></A>
1671 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
1672 Note that this file format doesn't support plural forms.
1673
1674 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
1675 <DD>
1676 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
1677 <DD>
1678 <A NAME="IDX777"></A>
1679 <A NAME="IDX778"></A>
1680 Set the output page width.  Long strings in the output files will be
1681 split across multiple lines in order to ensure that each line's width
1682 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
1683
1684 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
1685 <DD>
1686 <A NAME="IDX779"></A>
1687 Do not break long message lines.  Message lines whose width exceeds the
1688 output page width will not be split into several lines.  Only file reference
1689 lines which are wider than the output page width will be split.
1690
1691 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
1692 <DD>
1693 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
1694 <DD>
1695 <A NAME="IDX780"></A>
1696 <A NAME="IDX781"></A>
1697 Generate sorted output.  Note that using this option makes it much harder
1698 for the translator to understand each message's context.
1699
1700 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
1701 <DD>
1702 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
1703 <DD>
1704 <A NAME="IDX782"></A>
1705 <A NAME="IDX783"></A>
1706 Sort output by file location.
1707
1708 </DL>
1709
1710
1711
1712 <H3><A NAME="SEC118" HREF="gettext_toc.html#TOC118">9.5.6  Informative output</A></H3>
1713
1714 <DL COMPACT>
1715
1716 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
1717 <DD>
1718 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
1719 <DD>
1720 <A NAME="IDX784"></A>
1721 <A NAME="IDX785"></A>
1722 Display this help and exit.
1723
1724 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
1725 <DD>
1726 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
1727 <DD>
1728 <A NAME="IDX786"></A>
1729 <A NAME="IDX787"></A>
1730 Output version information and exit.
1731
1732 </DL>
1733
1734
1735
1736 <H2><A NAME="SEC119" HREF="gettext_toc.html#TOC119">9.6  Invoking the <CODE>msgcomm</CODE> Program</A></H2>
1737
1738 <P>
1739 <A NAME="IDX788"></A>
1740 <A NAME="IDX789"></A>
1741
1742 <PRE>
1743 msgcomm [<VAR>option</VAR>] [<VAR>inputfile</VAR>]...
1744 </PRE>
1745
1746 <P>
1747 <A NAME="IDX790"></A>
1748 The <CODE>msgcomm</CODE> program finds messages which are common to two or more
1749 of the specified PO files.
1750 By using the <CODE>--more-than</CODE> option, greater commonality may be requested
1751 before messages are printed.  Conversely, the <CODE>--less-than</CODE> option may be
1752 used to specify less commonality before messages are printed (i.e.
1753 <SAMP>&lsquo;--less-than=2&rsquo;</SAMP> will only print the unique messages).  Translations,
1754 comments and extracted comments will be preserved, but only from the first
1755 PO file to define them.  File positions from all PO files will be
1756 cumulated.
1757
1758 </P>
1759
1760
1761 <H3><A NAME="SEC120" HREF="gettext_toc.html#TOC120">9.6.1  Input file location</A></H3>
1762
1763 <DL COMPACT>
1764
1765 <DT><SAMP>&lsquo;<VAR>inputfile</VAR> ...&rsquo;</SAMP>
1766 <DD>
1767 Input files.
1768
1769 <DT><SAMP>&lsquo;-f <VAR>file</VAR>&rsquo;</SAMP>
1770 <DD>
1771 <DT><SAMP>&lsquo;--files-from=<VAR>file</VAR>&rsquo;</SAMP>
1772 <DD>
1773 <A NAME="IDX791"></A>
1774 <A NAME="IDX792"></A>
1775 Read the names of the input files from <VAR>file</VAR> instead of getting
1776 them from the command line.
1777
1778 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
1779 <DD>
1780 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
1781 <DD>
1782 <A NAME="IDX793"></A>
1783 <A NAME="IDX794"></A>
1784 Add <VAR>directory</VAR> to the list of directories.  Source files are
1785 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
1786 file will be written relative to the current directory, though.
1787
1788 </DL>
1789
1790 <P>
1791 If <VAR>inputfile</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
1792
1793 </P>
1794
1795
1796 <H3><A NAME="SEC121" HREF="gettext_toc.html#TOC121">9.6.2  Output file location</A></H3>
1797
1798 <DL COMPACT>
1799
1800 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
1801 <DD>
1802 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
1803 <DD>
1804 <A NAME="IDX795"></A>
1805 <A NAME="IDX796"></A>
1806 Write output to specified file.
1807
1808 </DL>
1809
1810 <P>
1811 The results are written to standard output if no output file is specified
1812 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
1813
1814 </P>
1815
1816
1817 <H3><A NAME="SEC122" HREF="gettext_toc.html#TOC122">9.6.3  Message selection</A></H3>
1818
1819 <DL COMPACT>
1820
1821 <DT><SAMP>&lsquo;-&#60; <VAR>number</VAR>&rsquo;</SAMP>
1822 <DD>
1823 <DT><SAMP>&lsquo;--less-than=<VAR>number</VAR>&rsquo;</SAMP>
1824 <DD>
1825 <A NAME="IDX797"></A>
1826 <A NAME="IDX798"></A>
1827 Print messages with less than <VAR>number</VAR> definitions, defaults to infinite
1828 if not set.
1829
1830 <DT><SAMP>&lsquo;-&#62; <VAR>number</VAR>&rsquo;</SAMP>
1831 <DD>
1832 <DT><SAMP>&lsquo;--more-than=<VAR>number</VAR>&rsquo;</SAMP>
1833 <DD>
1834 <A NAME="IDX799"></A>
1835 <A NAME="IDX800"></A>
1836 Print messages with more than <VAR>number</VAR> definitions, defaults to 1 if not
1837 set.
1838
1839 <DT><SAMP>&lsquo;-u&rsquo;</SAMP>
1840 <DD>
1841 <DT><SAMP>&lsquo;--unique&rsquo;</SAMP>
1842 <DD>
1843 <A NAME="IDX801"></A>
1844 <A NAME="IDX802"></A>
1845 Shorthand for <SAMP>&lsquo;--less-than=2&rsquo;</SAMP>.  Requests that only unique messages be
1846 printed.
1847
1848 </DL>
1849
1850
1851
1852 <H3><A NAME="SEC123" HREF="gettext_toc.html#TOC123">9.6.4  Input file syntax</A></H3>
1853
1854 <DL COMPACT>
1855
1856 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
1857 <DD>
1858 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
1859 <DD>
1860 <A NAME="IDX803"></A>
1861 <A NAME="IDX804"></A>
1862 Assume the input files are Java ResourceBundles in Java <CODE>.properties</CODE>
1863 syntax, not in PO file syntax.
1864
1865 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
1866 <DD>
1867 <A NAME="IDX805"></A>
1868 Assume the input files are NeXTstep/GNUstep localized resource files in
1869 <CODE>.strings</CODE> syntax, not in PO file syntax.
1870
1871 </DL>
1872
1873
1874
1875 <H3><A NAME="SEC124" HREF="gettext_toc.html#TOC124">9.6.5  Output details</A></H3>
1876
1877 <DL COMPACT>
1878
1879 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
1880 <DD>
1881 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
1882 <DD>
1883 <A NAME="IDX806"></A>
1884 Specify whether or when to use colors and other text attributes.
1885 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
1886
1887 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
1888 <DD>
1889 <A NAME="IDX807"></A>
1890 Specify the CSS style rule file to use for <CODE>--color</CODE>.
1891 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
1892
1893 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
1894 <DD>
1895 <A NAME="IDX808"></A>
1896 Always write an output file even if it contains no message.
1897
1898 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
1899 <DD>
1900 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
1901 <DD>
1902 <A NAME="IDX809"></A>
1903 <A NAME="IDX810"></A>
1904 Write the .po file using indented style.
1905
1906 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
1907 <DD>
1908 <A NAME="IDX811"></A>
1909 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
1910
1911 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
1912 <DD>
1913 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
1914 <DD>
1915 <A NAME="IDX812"></A>
1916 <A NAME="IDX813"></A>
1917 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
1918
1919 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
1920 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
1921 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
1922 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
1923 suppresses the lines (same as <CODE>--no-location</CODE>).
1924
1925 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
1926 <DD>
1927 <A NAME="IDX814"></A>
1928 Write out a strict Uniforum conforming PO file.  Note that this
1929 Uniforum format should be avoided because it doesn't support the
1930 GNU extensions.
1931
1932 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
1933 <DD>
1934 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
1935 <DD>
1936 <A NAME="IDX815"></A>
1937 <A NAME="IDX816"></A>
1938 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
1939 that this file format doesn't support plural forms and silently drops
1940 obsolete messages.
1941
1942 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
1943 <DD>
1944 <A NAME="IDX817"></A>
1945 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
1946 Note that this file format doesn't support plural forms.
1947
1948 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
1949 <DD>
1950 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
1951 <DD>
1952 <A NAME="IDX818"></A>
1953 <A NAME="IDX819"></A>
1954 Set the output page width.  Long strings in the output files will be
1955 split across multiple lines in order to ensure that each line's width
1956 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
1957
1958 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
1959 <DD>
1960 <A NAME="IDX820"></A>
1961 Do not break long message lines.  Message lines whose width exceeds the
1962 output page width will not be split into several lines.  Only file reference
1963 lines which are wider than the output page width will be split.
1964
1965 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
1966 <DD>
1967 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
1968 <DD>
1969 <A NAME="IDX821"></A>
1970 <A NAME="IDX822"></A>
1971 Generate sorted output.  Note that using this option makes it much harder
1972 for the translator to understand each message's context.
1973
1974 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
1975 <DD>
1976 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
1977 <DD>
1978 <A NAME="IDX823"></A>
1979 <A NAME="IDX824"></A>
1980 Sort output by file location.
1981
1982 <DT><SAMP>&lsquo;--omit-header&rsquo;</SAMP>
1983 <DD>
1984 <A NAME="IDX825"></A>
1985 Don't write header with <SAMP>&lsquo;msgid ""&rsquo;</SAMP> entry.
1986
1987 </DL>
1988
1989
1990
1991 <H3><A NAME="SEC125" HREF="gettext_toc.html#TOC125">9.6.6  Informative output</A></H3>
1992
1993 <DL COMPACT>
1994
1995 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
1996 <DD>
1997 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
1998 <DD>
1999 <A NAME="IDX826"></A>
2000 <A NAME="IDX827"></A>
2001 Display this help and exit.
2002
2003 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
2004 <DD>
2005 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
2006 <DD>
2007 <A NAME="IDX828"></A>
2008 <A NAME="IDX829"></A>
2009 Output version information and exit.
2010
2011 </DL>
2012
2013
2014
2015 <H2><A NAME="SEC126" HREF="gettext_toc.html#TOC126">9.7  Invoking the <CODE>msgcmp</CODE> Program</A></H2>
2016
2017 <P>
2018 <A NAME="IDX830"></A>
2019 <A NAME="IDX831"></A>
2020
2021 <PRE>
2022 msgcmp [<VAR>option</VAR>] <VAR>def</VAR>.po <VAR>ref</VAR>.pot
2023 </PRE>
2024
2025 <P>
2026 <A NAME="IDX832"></A>
2027 The <CODE>msgcmp</CODE> program compares two Uniforum style .po files to check that
2028 both contain the same set of msgid strings.  The <VAR>def</VAR>.po file is an
2029 existing PO file with the translations.  The <VAR>ref</VAR>.pot file is the last
2030 created PO file, or a PO Template file (generally created by <CODE>xgettext</CODE>).
2031 This is useful for checking that you have translated each and every message
2032 in your program.  Where an exact match cannot be found, fuzzy matching is
2033 used to produce better diagnostics.
2034
2035 </P>
2036
2037
2038 <H3><A NAME="SEC127" HREF="gettext_toc.html#TOC127">9.7.1  Input file location</A></H3>
2039
2040 <DL COMPACT>
2041
2042 <DT><SAMP>&lsquo;<VAR>def</VAR>.po&rsquo;</SAMP>
2043 <DD>
2044 Translations.
2045
2046 <DT><SAMP>&lsquo;<VAR>ref</VAR>.pot&rsquo;</SAMP>
2047 <DD>
2048 References to the sources.
2049
2050 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
2051 <DD>
2052 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
2053 <DD>
2054 <A NAME="IDX833"></A>
2055 <A NAME="IDX834"></A>
2056 Add <VAR>directory</VAR> to the list of directories.  Source files are
2057 searched relative to this list of directories.
2058
2059 </DL>
2060
2061
2062
2063 <H3><A NAME="SEC128" HREF="gettext_toc.html#TOC128">9.7.2  Operation modifiers</A></H3>
2064
2065 <DL COMPACT>
2066
2067 <DT><SAMP>&lsquo;-m&rsquo;</SAMP>
2068 <DD>
2069 <DT><SAMP>&lsquo;--multi-domain&rsquo;</SAMP>
2070 <DD>
2071 <A NAME="IDX835"></A>
2072 <A NAME="IDX836"></A>
2073 Apply <VAR>ref</VAR>.pot to each of the domains in <VAR>def</VAR>.po.
2074
2075 <DT><SAMP>&lsquo;-N&rsquo;</SAMP>
2076 <DD>
2077 <DT><SAMP>&lsquo;--no-fuzzy-matching&rsquo;</SAMP>
2078 <DD>
2079 <A NAME="IDX837"></A>
2080 <A NAME="IDX838"></A>
2081 Do not use fuzzy matching when an exact match is not found.  This may speed
2082 up the operation considerably.
2083
2084 <DT><SAMP>&lsquo;--use-fuzzy&rsquo;</SAMP>
2085 <DD>
2086 <A NAME="IDX839"></A>
2087 Consider fuzzy messages in the <VAR>def</VAR>.po file like translated messages.
2088 Note that using this option is usually wrong, because fuzzy messages are
2089 exactly those which have not been validated by a human translator.
2090
2091 <DT><SAMP>&lsquo;--use-untranslated&rsquo;</SAMP>
2092 <DD>
2093 <A NAME="IDX840"></A>
2094 Consider untranslated messages in the <VAR>def</VAR>.po file like translated
2095 messages.  Note that using this option is usually wrong.
2096
2097 </DL>
2098
2099
2100
2101 <H3><A NAME="SEC129" HREF="gettext_toc.html#TOC129">9.7.3  Input file syntax</A></H3>
2102
2103 <DL COMPACT>
2104
2105 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
2106 <DD>
2107 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
2108 <DD>
2109 <A NAME="IDX841"></A>
2110 <A NAME="IDX842"></A>
2111 Assume the input files are Java ResourceBundles in Java <CODE>.properties</CODE>
2112 syntax, not in PO file syntax.
2113
2114 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
2115 <DD>
2116 <A NAME="IDX843"></A>
2117 Assume the input files are NeXTstep/GNUstep localized resource files in
2118 <CODE>.strings</CODE> syntax, not in PO file syntax.
2119
2120 </DL>
2121
2122
2123
2124 <H3><A NAME="SEC130" HREF="gettext_toc.html#TOC130">9.7.4  Informative output</A></H3>
2125
2126 <DL COMPACT>
2127
2128 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
2129 <DD>
2130 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
2131 <DD>
2132 <A NAME="IDX844"></A>
2133 <A NAME="IDX845"></A>
2134 Display this help and exit.
2135
2136 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
2137 <DD>
2138 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
2139 <DD>
2140 <A NAME="IDX846"></A>
2141 <A NAME="IDX847"></A>
2142 Output version information and exit.
2143
2144 </DL>
2145
2146
2147
2148 <H2><A NAME="SEC131" HREF="gettext_toc.html#TOC131">9.8  Invoking the <CODE>msgattrib</CODE> Program</A></H2>
2149
2150 <P>
2151 <A NAME="IDX848"></A>
2152 <A NAME="IDX849"></A>
2153
2154 <PRE>
2155 msgattrib [<VAR>option</VAR>] [<VAR>inputfile</VAR>]
2156 </PRE>
2157
2158 <P>
2159 <A NAME="IDX850"></A>
2160 <A NAME="IDX851"></A>
2161 The <CODE>msgattrib</CODE> program filters the messages of a translation catalog
2162 according to their attributes, and manipulates the attributes.
2163
2164 </P>
2165
2166
2167 <H3><A NAME="SEC132" HREF="gettext_toc.html#TOC132">9.8.1  Input file location</A></H3>
2168
2169 <DL COMPACT>
2170
2171 <DT><SAMP>&lsquo;<VAR>inputfile</VAR>&rsquo;</SAMP>
2172 <DD>
2173 Input PO file.
2174
2175 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
2176 <DD>
2177 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
2178 <DD>
2179 <A NAME="IDX852"></A>
2180 <A NAME="IDX853"></A>
2181 Add <VAR>directory</VAR> to the list of directories.  Source files are
2182 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
2183 file will be written relative to the current directory, though.
2184
2185 </DL>
2186
2187 <P>
2188 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
2189
2190 </P>
2191
2192
2193 <H3><A NAME="SEC133" HREF="gettext_toc.html#TOC133">9.8.2  Output file location</A></H3>
2194
2195 <DL COMPACT>
2196
2197 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
2198 <DD>
2199 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
2200 <DD>
2201 <A NAME="IDX854"></A>
2202 <A NAME="IDX855"></A>
2203 Write output to specified file.
2204
2205 </DL>
2206
2207 <P>
2208 The results are written to standard output if no output file is specified
2209 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
2210
2211 </P>
2212
2213
2214 <H3><A NAME="SEC134" HREF="gettext_toc.html#TOC134">9.8.3  Message selection</A></H3>
2215
2216 <DL COMPACT>
2217
2218 <DT><SAMP>&lsquo;--translated&rsquo;</SAMP>
2219 <DD>
2220 <A NAME="IDX856"></A>
2221 Keep translated messages, remove untranslated messages.
2222
2223 <DT><SAMP>&lsquo;--untranslated&rsquo;</SAMP>
2224 <DD>
2225 <A NAME="IDX857"></A>
2226 Keep untranslated messages, remove translated messages.
2227
2228 <DT><SAMP>&lsquo;--no-fuzzy&rsquo;</SAMP>
2229 <DD>
2230 <A NAME="IDX858"></A>
2231 Remove
2232 ‘fuzzy’
2233 marked messages.
2234
2235 <DT><SAMP>&lsquo;--only-fuzzy&rsquo;</SAMP>
2236 <DD>
2237 <A NAME="IDX859"></A>
2238 Keep
2239 ‘fuzzy’
2240 marked messages, remove all other messages.
2241
2242 <DT><SAMP>&lsquo;--no-obsolete&rsquo;</SAMP>
2243 <DD>
2244 <A NAME="IDX860"></A>
2245 Remove obsolete #~ messages.
2246
2247 <DT><SAMP>&lsquo;--only-obsolete&rsquo;</SAMP>
2248 <DD>
2249 <A NAME="IDX861"></A>
2250 Keep obsolete #~ messages, remove all other messages.
2251
2252 </DL>
2253
2254
2255
2256 <H3><A NAME="SEC135" HREF="gettext_toc.html#TOC135">9.8.4  Attribute manipulation</A></H3>
2257
2258 <P>
2259 <A NAME="IDX862"></A>
2260 Attributes are modified after the message selection/removal has been
2261 performed.  If the <SAMP>&lsquo;--only-file&rsquo;</SAMP> or <SAMP>&lsquo;--ignore-file&rsquo;</SAMP> option is
2262 specified, the attribute modification is applied only to those messages
2263 that are listed in the <VAR>only-file</VAR> and not listed in the
2264 <VAR>ignore-file</VAR>.
2265
2266 </P>
2267 <DL COMPACT>
2268
2269 <DT><SAMP>&lsquo;--set-fuzzy&rsquo;</SAMP>
2270 <DD>
2271 <A NAME="IDX863"></A>
2272 Set all messages
2273 ‘fuzzy’.
2274
2275 <DT><SAMP>&lsquo;--clear-fuzzy&rsquo;</SAMP>
2276 <DD>
2277 <A NAME="IDX864"></A>
2278 Set all messages
2279 non-‘fuzzy’.
2280
2281 <DT><SAMP>&lsquo;--set-obsolete&rsquo;</SAMP>
2282 <DD>
2283 <A NAME="IDX865"></A>
2284 Set all messages obsolete.
2285
2286 <DT><SAMP>&lsquo;--clear-obsolete&rsquo;</SAMP>
2287 <DD>
2288 <A NAME="IDX866"></A>
2289 Set all messages non-obsolete.
2290
2291 <DT><SAMP>&lsquo;--previous&rsquo;</SAMP>
2292 <DD>
2293 <A NAME="IDX867"></A>
2294 When setting
2295 ‘fuzzy’
2296 mark, keep “previous msgid” of translated messages.
2297
2298 <DT><SAMP>&lsquo;--clear-previous&rsquo;</SAMP>
2299 <DD>
2300 <A NAME="IDX868"></A>
2301 Remove the “previous msgid” (<SAMP>&lsquo;#|&rsquo;</SAMP>) comments from all messages.
2302
2303 <DT><SAMP>&lsquo;--empty&rsquo;</SAMP>
2304 <DD>
2305 <A NAME="IDX869"></A>
2306 When removing
2307 ‘fuzzy’
2308 mark, also set msgstr empty.
2309
2310 <DT><SAMP>&lsquo;--only-file=<VAR>file</VAR>&rsquo;</SAMP>
2311 <DD>
2312 <A NAME="IDX870"></A>
2313 Limit the attribute changes to entries that are listed in <VAR>file</VAR>.
2314 <VAR>file</VAR> should be a PO or POT file.
2315
2316 <DT><SAMP>&lsquo;--ignore-file=<VAR>file</VAR>&rsquo;</SAMP>
2317 <DD>
2318 <A NAME="IDX871"></A>
2319 Limit the attribute changes to entries that are not listed in <VAR>file</VAR>.
2320 <VAR>file</VAR> should be a PO or POT file.
2321
2322 <DT><SAMP>&lsquo;--fuzzy&rsquo;</SAMP>
2323 <DD>
2324 <A NAME="IDX872"></A>
2325 Synonym for <SAMP>&lsquo;--only-fuzzy --clear-fuzzy&rsquo;</SAMP>: It keeps only the fuzzy
2326 messages and removes their
2327 ‘fuzzy’
2328 mark.
2329
2330 <DT><SAMP>&lsquo;--obsolete&rsquo;</SAMP>
2331 <DD>
2332 <A NAME="IDX873"></A>
2333 Synonym for <SAMP>&lsquo;--only-obsolete --clear-obsolete&rsquo;</SAMP>: It keeps only the
2334 obsolete messages and makes them non-obsolete.
2335
2336 </DL>
2337
2338
2339
2340 <H3><A NAME="SEC136" HREF="gettext_toc.html#TOC136">9.8.5  Input file syntax</A></H3>
2341
2342 <DL COMPACT>
2343
2344 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
2345 <DD>
2346 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
2347 <DD>
2348 <A NAME="IDX874"></A>
2349 <A NAME="IDX875"></A>
2350 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
2351 syntax, not in PO file syntax.
2352
2353 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
2354 <DD>
2355 <A NAME="IDX876"></A>
2356 Assume the input file is a NeXTstep/GNUstep localized resource file in
2357 <CODE>.strings</CODE> syntax, not in PO file syntax.
2358
2359 </DL>
2360
2361
2362
2363 <H3><A NAME="SEC137" HREF="gettext_toc.html#TOC137">9.8.6  Output details</A></H3>
2364
2365 <DL COMPACT>
2366
2367 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
2368 <DD>
2369 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
2370 <DD>
2371 <A NAME="IDX877"></A>
2372 Specify whether or when to use colors and other text attributes.
2373 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
2374
2375 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
2376 <DD>
2377 <A NAME="IDX878"></A>
2378 Specify the CSS style rule file to use for <CODE>--color</CODE>.
2379 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
2380
2381 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
2382 <DD>
2383 <A NAME="IDX879"></A>
2384 Always write an output file even if it contains no message.
2385
2386 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
2387 <DD>
2388 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
2389 <DD>
2390 <A NAME="IDX880"></A>
2391 <A NAME="IDX881"></A>
2392 Write the .po file using indented style.
2393
2394 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
2395 <DD>
2396 <A NAME="IDX882"></A>
2397 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
2398
2399 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
2400 <DD>
2401 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
2402 <DD>
2403 <A NAME="IDX883"></A>
2404 <A NAME="IDX884"></A>
2405 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
2406
2407 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
2408 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
2409 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
2410 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
2411 suppresses the lines (same as <CODE>--no-location</CODE>).
2412
2413 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
2414 <DD>
2415 <A NAME="IDX885"></A>
2416 Write out a strict Uniforum conforming PO file.  Note that this
2417 Uniforum format should be avoided because it doesn't support the
2418 GNU extensions.
2419
2420 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
2421 <DD>
2422 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
2423 <DD>
2424 <A NAME="IDX886"></A>
2425 <A NAME="IDX887"></A>
2426 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
2427 that this file format doesn't support plural forms and silently drops
2428 obsolete messages.
2429
2430 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
2431 <DD>
2432 <A NAME="IDX888"></A>
2433 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
2434 Note that this file format doesn't support plural forms.
2435
2436 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
2437 <DD>
2438 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
2439 <DD>
2440 <A NAME="IDX889"></A>
2441 <A NAME="IDX890"></A>
2442 Set the output page width.  Long strings in the output files will be
2443 split across multiple lines in order to ensure that each line's width
2444 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
2445
2446 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
2447 <DD>
2448 <A NAME="IDX891"></A>
2449 Do not break long message lines.  Message lines whose width exceeds the
2450 output page width will not be split into several lines.  Only file reference
2451 lines which are wider than the output page width will be split.
2452
2453 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
2454 <DD>
2455 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
2456 <DD>
2457 <A NAME="IDX892"></A>
2458 <A NAME="IDX893"></A>
2459 Generate sorted output.  Note that using this option makes it much harder
2460 for the translator to understand each message's context.
2461
2462 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
2463 <DD>
2464 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
2465 <DD>
2466 <A NAME="IDX894"></A>
2467 <A NAME="IDX895"></A>
2468 Sort output by file location.
2469
2470 </DL>
2471
2472
2473
2474 <H3><A NAME="SEC138" HREF="gettext_toc.html#TOC138">9.8.7  Informative output</A></H3>
2475
2476 <DL COMPACT>
2477
2478 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
2479 <DD>
2480 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
2481 <DD>
2482 <A NAME="IDX896"></A>
2483 <A NAME="IDX897"></A>
2484 Display this help and exit.
2485
2486 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
2487 <DD>
2488 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
2489 <DD>
2490 <A NAME="IDX898"></A>
2491 <A NAME="IDX899"></A>
2492 Output version information and exit.
2493
2494 </DL>
2495
2496
2497
2498 <H2><A NAME="SEC139" HREF="gettext_toc.html#TOC139">9.9  Invoking the <CODE>msgen</CODE> Program</A></H2>
2499
2500 <P>
2501 <A NAME="IDX900"></A>
2502 <A NAME="IDX901"></A>
2503
2504 <PRE>
2505 msgen [<VAR>option</VAR>] <VAR>inputfile</VAR>
2506 </PRE>
2507
2508 <P>
2509 <A NAME="IDX902"></A>
2510 The <CODE>msgen</CODE> program creates an English translation catalog.  The
2511 input file is the last created English PO file, or a PO Template file
2512 (generally created by xgettext).  Untranslated entries are assigned a
2513 translation that is identical to the msgid.
2514
2515 </P>
2516 <P>
2517 Note: <SAMP>&lsquo;msginit --no-translator --locale=en&rsquo;</SAMP> performs a very similar
2518 task.  The main difference is that <CODE>msginit</CODE> cares specially about
2519 the header entry, whereas <CODE>msgen</CODE> doesn't.
2520
2521 </P>
2522
2523
2524 <H3><A NAME="SEC140" HREF="gettext_toc.html#TOC140">9.9.1  Input file location</A></H3>
2525
2526 <DL COMPACT>
2527
2528 <DT><SAMP>&lsquo;<VAR>inputfile</VAR>&rsquo;</SAMP>
2529 <DD>
2530 Input PO or POT file.
2531
2532 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
2533 <DD>
2534 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
2535 <DD>
2536 <A NAME="IDX903"></A>
2537 <A NAME="IDX904"></A>
2538 Add <VAR>directory</VAR> to the list of directories.  Source files are
2539 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
2540 file will be written relative to the current directory, though.
2541
2542 </DL>
2543
2544 <P>
2545 If <VAR>inputfile</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
2546
2547 </P>
2548
2549
2550 <H3><A NAME="SEC141" HREF="gettext_toc.html#TOC141">9.9.2  Output file location</A></H3>
2551
2552 <DL COMPACT>
2553
2554 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
2555 <DD>
2556 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
2557 <DD>
2558 <A NAME="IDX905"></A>
2559 <A NAME="IDX906"></A>
2560 Write output to specified file.
2561
2562 </DL>
2563
2564 <P>
2565 The results are written to standard output if no output file is specified
2566 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
2567
2568 </P>
2569
2570
2571 <H3><A NAME="SEC142" HREF="gettext_toc.html#TOC142">9.9.3  Input file syntax</A></H3>
2572
2573 <DL COMPACT>
2574
2575 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
2576 <DD>
2577 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
2578 <DD>
2579 <A NAME="IDX907"></A>
2580 <A NAME="IDX908"></A>
2581 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
2582 syntax, not in PO file syntax.
2583
2584 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
2585 <DD>
2586 <A NAME="IDX909"></A>
2587 Assume the input file is a NeXTstep/GNUstep localized resource file in
2588 <CODE>.strings</CODE> syntax, not in PO file syntax.
2589
2590 </DL>
2591
2592
2593
2594 <H3><A NAME="SEC143" HREF="gettext_toc.html#TOC143">9.9.4  Output details</A></H3>
2595
2596 <DL COMPACT>
2597
2598 <DT><SAMP>&lsquo;--lang=<VAR>catalogname</VAR>&rsquo;</SAMP>
2599 <DD>
2600 <A NAME="IDX910"></A>
2601 Specify the <SAMP>&lsquo;Language&rsquo;</SAMP> field to be used in the header entry.  See
2602 section <A HREF="gettext_6.html#SEC44">6.2  Filling in the Header Entry</A> for the meaning of this field.  Note: The
2603 <SAMP>&lsquo;Language-Team&rsquo;</SAMP> and <SAMP>&lsquo;Plural-Forms&rsquo;</SAMP> fields are not set by this
2604 option.
2605
2606 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
2607 <DD>
2608 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
2609 <DD>
2610 <A NAME="IDX911"></A>
2611 Specify whether or when to use colors and other text attributes.
2612 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
2613
2614 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
2615 <DD>
2616 <A NAME="IDX912"></A>
2617 Specify the CSS style rule file to use for <CODE>--color</CODE>.
2618 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
2619
2620 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
2621 <DD>
2622 <A NAME="IDX913"></A>
2623 Always write an output file even if it contains no message.
2624
2625 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
2626 <DD>
2627 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
2628 <DD>
2629 <A NAME="IDX914"></A>
2630 <A NAME="IDX915"></A>
2631 Write the .po file using indented style.
2632
2633 <DT><SAMP>&lsquo;--no-location&rsquo;</SAMP>
2634 <DD>
2635 <A NAME="IDX916"></A>
2636 Do not write <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines.
2637
2638 <DT><SAMP>&lsquo;-n&rsquo;</SAMP>
2639 <DD>
2640 <DT><SAMP>&lsquo;--add-location=<VAR>type</VAR>&rsquo;</SAMP>
2641 <DD>
2642 <A NAME="IDX917"></A>
2643 Generate <SAMP>&lsquo;#: <VAR>filename</VAR>:<VAR>line</VAR>&rsquo;</SAMP> lines (default).
2644
2645 The optional <VAR>type</VAR> can be either <SAMP>&lsquo;full&rsquo;</SAMP>, <SAMP>&lsquo;file&rsquo;</SAMP>, or
2646 <SAMP>&lsquo;never&rsquo;</SAMP>.  If it is not given or <SAMP>&lsquo;full&rsquo;</SAMP>, it generates the
2647 lines with both file name and line number.  If it is <SAMP>&lsquo;file&rsquo;</SAMP>, the
2648 line number part is omitted.  If it is <SAMP>&lsquo;never&rsquo;</SAMP>, it completely
2649 suppresses the lines (same as <CODE>--no-location</CODE>).
2650
2651 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
2652 <DD>
2653 <A NAME="IDX918"></A>
2654 Write out a strict Uniforum conforming PO file.  Note that this
2655 Uniforum format should be avoided because it doesn't support the
2656 GNU extensions.
2657
2658 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
2659 <DD>
2660 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
2661 <DD>
2662 <A NAME="IDX919"></A>
2663 <A NAME="IDX920"></A>
2664 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
2665 that this file format doesn't support plural forms and silently drops
2666 obsolete messages.
2667
2668 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
2669 <DD>
2670 <A NAME="IDX921"></A>
2671 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
2672 Note that this file format doesn't support plural forms.
2673
2674 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
2675 <DD>
2676 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
2677 <DD>
2678 <A NAME="IDX922"></A>
2679 <A NAME="IDX923"></A>
2680 Set the output page width.  Long strings in the output files will be
2681 split across multiple lines in order to ensure that each line's width
2682 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
2683
2684 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
2685 <DD>
2686 <A NAME="IDX924"></A>
2687 Do not break long message lines.  Message lines whose width exceeds the
2688 output page width will not be split into several lines.  Only file reference
2689 lines which are wider than the output page width will be split.
2690
2691 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
2692 <DD>
2693 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
2694 <DD>
2695 <A NAME="IDX925"></A>
2696 <A NAME="IDX926"></A>
2697 Generate sorted output.  Note that using this option makes it much harder
2698 for the translator to understand each message's context.
2699
2700 <DT><SAMP>&lsquo;-F&rsquo;</SAMP>
2701 <DD>
2702 <DT><SAMP>&lsquo;--sort-by-file&rsquo;</SAMP>
2703 <DD>
2704 <A NAME="IDX927"></A>
2705 <A NAME="IDX928"></A>
2706 Sort output by file location.
2707
2708 </DL>
2709
2710
2711
2712 <H3><A NAME="SEC144" HREF="gettext_toc.html#TOC144">9.9.5  Informative output</A></H3>
2713
2714 <DL COMPACT>
2715
2716 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
2717 <DD>
2718 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
2719 <DD>
2720 <A NAME="IDX929"></A>
2721 <A NAME="IDX930"></A>
2722 Display this help and exit.
2723
2724 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
2725 <DD>
2726 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
2727 <DD>
2728 <A NAME="IDX931"></A>
2729 <A NAME="IDX932"></A>
2730 Output version information and exit.
2731
2732 </DL>
2733
2734
2735
2736 <H2><A NAME="SEC145" HREF="gettext_toc.html#TOC145">9.10  Invoking the <CODE>msgexec</CODE> Program</A></H2>
2737
2738 <P>
2739 <A NAME="IDX933"></A>
2740 <A NAME="IDX934"></A>
2741
2742 <PRE>
2743 msgexec [<VAR>option</VAR>] <VAR>command</VAR> [<VAR>command-option</VAR>]
2744 </PRE>
2745
2746 <P>
2747 <A NAME="IDX935"></A>
2748 The <CODE>msgexec</CODE> program applies a command to all translations of a
2749 translation catalog.
2750 The <VAR>command</VAR> can be any program that reads a translation from standard
2751 input.  It is invoked once for each translation.  Its output becomes
2752 msgexec's output.  <CODE>msgexec</CODE>'s return code is the maximum return code
2753 across all invocations.
2754
2755 </P>
2756 <P>
2757 <A NAME="IDX936"></A>
2758 A special builtin command called <SAMP>&lsquo;0&rsquo;</SAMP> outputs the translation, followed
2759 by a null byte.  The output of <SAMP>&lsquo;msgexec 0&rsquo;</SAMP> is suitable as input for
2760 <SAMP>&lsquo;xargs -0&rsquo;</SAMP>.
2761
2762 </P>
2763 <DL COMPACT>
2764
2765 <DT><SAMP>&lsquo;--newline&rsquo;</SAMP>
2766 <DD>
2767 <A NAME="IDX937"></A>
2768 Add newline at the end of each input line.
2769
2770 </DL>
2771
2772 <P>
2773 <A NAME="IDX938"></A>
2774 <A NAME="IDX939"></A>
2775 <A NAME="IDX940"></A>
2776 <A NAME="IDX941"></A>
2777 <A NAME="IDX942"></A>
2778 <A NAME="IDX943"></A>
2779 <A NAME="IDX944"></A>
2780 <A NAME="IDX945"></A>
2781 During each <VAR>command</VAR> invocation, the environment variable
2782 <CODE>MSGEXEC_MSGID</CODE> is bound to the message's msgid, and the environment
2783 variable <CODE>MSGEXEC_LOCATION</CODE> is bound to the location in the PO file
2784 of the message.  If the message has a context, the environment variable
2785 <CODE>MSGEXEC_MSGCTXT</CODE> is bound to the message's msgctxt, otherwise it is
2786 unbound.  If the message has a plural form, environment variable
2787 <CODE>MSGEXEC_MSGID_PLURAL</CODE> is bound to the message's msgid_plural and
2788 <CODE>MSGEXEC_PLURAL_FORM</CODE> is bound to the order number of the plural
2789 actually processed (starting with 0), otherwise both are unbound.
2790 If the message has a previous msgid (added by <CODE>msgmerge</CODE>),
2791 environment variable <CODE>MSGEXEC_PREV_MSGCTXT</CODE> is bound to the
2792 message's previous msgctxt, <CODE>MSGEXEC_PREV_MSGID</CODE> is bound to
2793 the previous msgid, and <CODE>MSGEXEC_PREV_MSGID_PLURAL</CODE> is bound to
2794 the previous msgid_plural.
2795
2796 </P>
2797 <P>
2798 <A NAME="IDX946"></A>
2799 Note: It is your responsibility to ensure that the <VAR>command</VAR> can cope
2800 with input encoded in the translation catalog's encoding.  If the
2801 <VAR>command</VAR> wants input in a particular encoding, you can in a first step
2802 convert the translation catalog to that encoding using the <SAMP>&lsquo;msgconv&rsquo;</SAMP>
2803 program, before invoking <SAMP>&lsquo;msgexec&rsquo;</SAMP>.  If the <VAR>command</VAR> wants input
2804 in the locale's encoding, but you want to avoid the locale's encoding, then
2805 you can first convert the translation catalog to UTF-8 using the
2806 <SAMP>&lsquo;msgconv&rsquo;</SAMP> program and then make <SAMP>&lsquo;msgexec&rsquo;</SAMP> work in an UTF-8
2807 locale, by using the <CODE>LC_ALL</CODE> environment variable.
2808
2809 </P>
2810
2811
2812 <H3><A NAME="SEC146" HREF="gettext_toc.html#TOC146">9.10.1  Input file location</A></H3>
2813
2814 <DL COMPACT>
2815
2816 <DT><SAMP>&lsquo;-i <VAR>inputfile</VAR>&rsquo;</SAMP>
2817 <DD>
2818 <DT><SAMP>&lsquo;--input=<VAR>inputfile</VAR>&rsquo;</SAMP>
2819 <DD>
2820 <A NAME="IDX947"></A>
2821 <A NAME="IDX948"></A>
2822 Input PO file.
2823
2824 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
2825 <DD>
2826 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
2827 <DD>
2828 <A NAME="IDX949"></A>
2829 <A NAME="IDX950"></A>
2830 Add <VAR>directory</VAR> to the list of directories.  Source files are
2831 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
2832 file will be written relative to the current directory, though.
2833
2834 </DL>
2835
2836 <P>
2837 If no <VAR>inputfile</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
2838
2839 </P>
2840
2841
2842 <H3><A NAME="SEC147" HREF="gettext_toc.html#TOC147">9.10.2  Input file syntax</A></H3>
2843
2844 <DL COMPACT>
2845
2846 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
2847 <DD>
2848 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
2849 <DD>
2850 <A NAME="IDX951"></A>
2851 <A NAME="IDX952"></A>
2852 Assume the input file is a Java ResourceBundle in Java <CODE>.properties</CODE>
2853 syntax, not in PO file syntax.
2854
2855 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
2856 <DD>
2857 <A NAME="IDX953"></A>
2858 Assume the input file is a NeXTstep/GNUstep localized resource file in
2859 <CODE>.strings</CODE> syntax, not in PO file syntax.
2860
2861 </DL>
2862
2863
2864
2865 <H3><A NAME="SEC148" HREF="gettext_toc.html#TOC148">9.10.3  Informative output</A></H3>
2866
2867 <DL COMPACT>
2868
2869 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
2870 <DD>
2871 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
2872 <DD>
2873 <A NAME="IDX954"></A>
2874 <A NAME="IDX955"></A>
2875 Display this help and exit.
2876
2877 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
2878 <DD>
2879 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
2880 <DD>
2881 <A NAME="IDX956"></A>
2882 <A NAME="IDX957"></A>
2883 Output version information and exit.
2884
2885 </DL>
2886
2887
2888
2889 <H2><A NAME="SEC149" HREF="gettext_toc.html#TOC149">9.11  Highlighting parts of PO files</A></H2>
2890
2891 <P>
2892 Translators are usually only interested in seeing the untranslated and
2893 fuzzy messages of a PO file.  Also, when a message is set fuzzy because
2894 the msgid changed, they want to see the differences between the previous
2895 msgid and the current one (especially if the msgid is long and only few
2896 words in it have changed).  Finally, it's always welcome to highlight the
2897 different sections of a message in a PO file (comments, msgid, msgstr, etc.).
2898
2899 </P>
2900 <P>
2901 Such highlighting is possible through the <CODE>msgcat</CODE> options
2902 <SAMP>&lsquo;--color&rsquo;</SAMP> and <SAMP>&lsquo;--style&rsquo;</SAMP>.
2903
2904 </P>
2905
2906
2907
2908 <H3><A NAME="SEC150" HREF="gettext_toc.html#TOC150">9.11.1  The <CODE>--color</CODE> option</A></H3>
2909
2910 <P>
2911 <A NAME="IDX958"></A>
2912 The <SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP> option specifies under which conditions
2913 colorized output should be generated.  The <VAR>when</VAR> part can be one of
2914 the following:
2915
2916 </P>
2917 <DL COMPACT>
2918
2919 <DT><CODE>always</CODE>
2920 <DD>
2921 <DT><CODE>yes</CODE>
2922 <DD>
2923 The output will be colorized.
2924
2925 <DT><CODE>never</CODE>
2926 <DD>
2927 <DT><CODE>no</CODE>
2928 <DD>
2929 The output will not be colorized.
2930
2931 <DT><CODE>auto</CODE>
2932 <DD>
2933 <DT><CODE>tty</CODE>
2934 <DD>
2935 The output will be colorized if the output device is a tty, i.e. when the
2936 output goes directly to a text screen or terminal emulator window.
2937
2938 <DT><CODE>html</CODE>
2939 <DD>
2940 The output will be colorized and be in HTML format.
2941 </DL>
2942
2943 <P>
2944 <SAMP>&lsquo;--color&rsquo;</SAMP> is equivalent to <SAMP>&lsquo;--color=yes&rsquo;</SAMP>.  The default is
2945 <SAMP>&lsquo;--color=auto&rsquo;</SAMP>.
2946
2947 </P>
2948 <P>
2949 Thus, a command like <SAMP>&lsquo;msgcat vi.po&rsquo;</SAMP> will produce colorized output
2950 when called by itself in a command window.  Whereas in a pipe, such as
2951 <SAMP>&lsquo;msgcat vi.po | less -R&rsquo;</SAMP>, it will not produce colorized output.  To
2952 get colorized output in this situation nevertheless, use the command
2953 <SAMP>&lsquo;msgcat --color vi.po | less -R&rsquo;</SAMP>.
2954
2955 </P>
2956 <P>
2957 The <SAMP>&lsquo;--color=html&rsquo;</SAMP> option will produce output that can be viewed in
2958 a browser.  This can be useful, for example, for Indic languages,
2959 because the renderic of Indic scripts in browser is usually better than
2960 in terminal emulators.
2961
2962 </P>
2963 <P>
2964 Note that the output produced with the <CODE>--color</CODE> option is <EM>not</EM>
2965 a valid PO file in itself.  It contains additional terminal-specific escape
2966 sequences or HTML tags.  A PO file reader will give a syntax error when
2967 confronted with such content.  Except for the <SAMP>&lsquo;--color=html&rsquo;</SAMP> case,
2968 you therefore normally don't need to save output produced with the
2969 <CODE>--color</CODE> option in a file.
2970
2971 </P>
2972
2973
2974 <H3><A NAME="SEC151" HREF="gettext_toc.html#TOC151">9.11.2  The environment variable <CODE>TERM</CODE></A></H3>
2975
2976 <P>
2977 <A NAME="IDX959"></A>
2978 The environment variable <CODE>TERM</CODE> contains a identifier for the text
2979 window's capabilities.  You can get a detailed list of these cababilities
2980 by using the <SAMP>&lsquo;infocmp&rsquo;</SAMP> command, using <SAMP>&lsquo;man 5 terminfo&rsquo;</SAMP> as a
2981 reference.
2982
2983 </P>
2984 <P>
2985 When producing text with embedded color directives, <CODE>msgcat</CODE> looks
2986 at the <CODE>TERM</CODE> variable.  Text windows today typically support at least
2987 8 colors.  Often, however, the text window supports 16 or more colors,
2988 even though the <CODE>TERM</CODE> variable is set to a identifier denoting only
2989 8 supported colors.  It can be worth setting the <CODE>TERM</CODE> variable to
2990 a different value in these cases:
2991
2992 </P>
2993 <DL COMPACT>
2994
2995 <DT><CODE>xterm</CODE>
2996 <DD>
2997 <CODE>xterm</CODE> is in most cases built with support for 16 colors.  It can also
2998 be built with support for 88 or 256 colors (but not both).  You can try to
2999 set <CODE>TERM</CODE> to either <CODE>xterm-16color</CODE>, <CODE>xterm-88color</CODE>, or
3000 <CODE>xterm-256color</CODE>.
3001
3002 <DT><CODE>rxvt</CODE>
3003 <DD>
3004 <CODE>rxvt</CODE> is often built with support for 16 colors.  You can try to set
3005 <CODE>TERM</CODE> to <CODE>rxvt-16color</CODE>.
3006
3007 <DT><CODE>konsole</CODE>
3008 <DD>
3009 <CODE>konsole</CODE> too is often built with support for 16 colors.  You can try to
3010 set <CODE>TERM</CODE> to <CODE>konsole-16color</CODE> or <CODE>xterm-16color</CODE>.
3011 </DL>
3012
3013 <P>
3014 After setting <CODE>TERM</CODE>, you can verify it by invoking
3015 <SAMP>&lsquo;msgcat --color=test&rsquo;</SAMP> and seeing whether the output looks like a
3016 reasonable color map.
3017
3018 </P>
3019
3020
3021 <H3><A NAME="SEC152" HREF="gettext_toc.html#TOC152">9.11.3  The <CODE>--style</CODE> option</A></H3>
3022
3023 <P>
3024 <A NAME="IDX960"></A>
3025 The <SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP> option specifies the style file to use
3026 when colorizing.  It has an effect only when the <CODE>--color</CODE> option is
3027 effective.
3028
3029 </P>
3030 <P>
3031 <A NAME="IDX961"></A>
3032 If the <CODE>--style</CODE> option is not specified, the environment variable
3033 <CODE>PO_STYLE</CODE> is considered.  It is meant to point to the user's
3034 preferred style for PO files.
3035
3036 </P>
3037 <P>
3038 The default style file is <TT>&lsquo;$prefix/share/gettext/styles/po-default.css&rsquo;</TT>,
3039 where <CODE>$prefix</CODE> is the installation location.
3040
3041 </P>
3042 <P>
3043 A few style files are predefined:
3044 <DL COMPACT>
3045
3046 <DT><TT>&lsquo;po-vim.css&rsquo;</TT>
3047 <DD>
3048 This style imitates the look used by vim 7.
3049
3050 <DT><TT>&lsquo;po-emacs-x.css&rsquo;</TT>
3051 <DD>
3052 This style imitates the look used by GNU Emacs 21 and 22 in an X11 window.
3053
3054 <DT><TT>&lsquo;po-emacs-xterm.css&rsquo;</TT>
3055 <DD>
3056 <DT><TT>&lsquo;po-emacs-xterm16.css&rsquo;</TT>
3057 <DD>
3058 <DT><TT>&lsquo;po-emacs-xterm256.css&rsquo;</TT>
3059 <DD>
3060 This style imitates the look used by GNU Emacs 22 in a terminal of type
3061 <SAMP>&lsquo;xterm&rsquo;</SAMP> (8 colors) or <SAMP>&lsquo;xterm-16color&rsquo;</SAMP> (16 colors) or
3062 <SAMP>&lsquo;xterm-256color&rsquo;</SAMP> (256 colors), respectively.
3063 </DL>
3064
3065 <P>
3066 You can use these styles without specifying a directory.  They are actually
3067 located in <TT>&lsquo;$prefix/share/gettext/styles/&rsquo;</TT>, where <CODE>$prefix</CODE> is the
3068 installation location.
3069
3070 </P>
3071 <P>
3072 You can also design your own styles.  This is described in the next section.
3073
3074 </P>
3075
3076
3077
3078 <H3><A NAME="SEC153" HREF="gettext_toc.html#TOC153">9.11.4  Style rules for PO files</A></H3>
3079
3080 <P>
3081 The same style file can be used for styling of a PO file, for terminal
3082 output and for HTML output.  It is written in CSS (Cascading Style Sheet)
3083 syntax.  See <A HREF="http://www.w3.org/TR/css2/cover.html">http://www.w3.org/TR/css2/cover.html</A> for a formal
3084 definition of CSS.  Many HTML authoring tutorials also contain explanations
3085 of CSS.
3086
3087 </P>
3088 <P>
3089 In the case of HTML output, the style file is embedded in the HTML output.
3090 In the case of text output, the style file is interpreted by the
3091 <CODE>msgcat</CODE> program.  This means, in particular, that when
3092 <CODE>@import</CODE> is used with relative file names, the file names are
3093
3094 </P>
3095
3096 <UL>
3097 <LI>
3098
3099 relative to the resulting HTML file, in the case of HTML output,
3100
3101 <LI>
3102
3103 relative to the style sheet containing the <CODE>@import</CODE>, in the case of
3104 text output.  (Actually, <CODE>@import</CODE>s are not yet supported in this case,
3105 due to a limitation in <CODE>libcroco</CODE>.)
3106 </UL>
3107
3108 <P>
3109 CSS rules are built up from selectors and declarations.  The declarations
3110 specify graphical properties; the selectors specify specify when they apply.
3111
3112 </P>
3113 <P>
3114 In PO files, the following simple selectors (based on "CSS classes", see
3115 the CSS2 spec, section 5.8.3) are supported.
3116
3117 </P>
3118
3119 <UL>
3120 <LI>
3121
3122 Selectors that apply to entire messages:
3123
3124 <DL COMPACT>
3125
3126 <DT><CODE>.header</CODE>
3127 <DD>
3128 This matches the header entry of a PO file.
3129
3130 <DT><CODE>.translated</CODE>
3131 <DD>
3132 This matches a translated message.
3133
3134 <DT><CODE>.untranslated</CODE>
3135 <DD>
3136 This matches an untranslated message (i.e. a message with empty translation).
3137
3138 <DT><CODE>.fuzzy</CODE>
3139 <DD>
3140 This matches a fuzzy message (i.e. a message which has a translation that
3141 needs review by the translator).
3142
3143 <DT><CODE>.obsolete</CODE>
3144 <DD>
3145 This matches an obsolete message (i.e. a message that was translated but is
3146 not needed by the current POT file any more).
3147 </DL>
3148
3149 <LI>
3150
3151 Selectors that apply to parts of a message in PO syntax.  Recall the general
3152 structure of a message in PO syntax:
3153
3154
3155 <PRE>
3156 <VAR>white-space</VAR>
3157 #  <VAR>translator-comments</VAR>
3158 #. <VAR>extracted-comments</VAR>
3159 #: <VAR>reference</VAR>...
3160 #, <VAR>flag</VAR>...
3161 #| msgid <VAR>previous-untranslated-string</VAR>
3162 msgid <VAR>untranslated-string</VAR>
3163 msgstr <VAR>translated-string</VAR>
3164 </PRE>
3165
3166 <DL COMPACT>
3167
3168 <DT><CODE>.comment</CODE>
3169 <DD>
3170 This matches all comments (translator comments, extracted comments,
3171 source file reference comments, flag comments, previous message comments,
3172 as well as the entire obsolete messages).
3173
3174 <DT><CODE>.translator-comment</CODE>
3175 <DD>
3176 This matches the translator comments.
3177
3178 <DT><CODE>.extracted-comment</CODE>
3179 <DD>
3180 This matches the extracted comments, i.e. the comments placed by the
3181 programmer at the attention of the translator.
3182
3183 <DT><CODE>.reference-comment</CODE>
3184 <DD>
3185 This matches the source file reference comments (entire lines).
3186
3187 <DT><CODE>.reference</CODE>
3188 <DD>
3189 This matches the individual source file references inside the source file
3190 reference comment lines.
3191
3192 <DT><CODE>.flag-comment</CODE>
3193 <DD>
3194 This matches the flag comment lines (entire lines).
3195
3196 <DT><CODE>.flag</CODE>
3197 <DD>
3198 This matches the individual flags inside flag comment lines.
3199
3200 <DT><CODE>.fuzzy-flag</CODE>
3201 <DD>
3202 This matches the `fuzzy' flag inside flag comment lines.
3203
3204 <DT><CODE>.previous-comment</CODE>
3205 <DD>
3206 This matches the comments containing the previous untranslated string (entire
3207 lines).
3208
3209 <DT><CODE>.previous</CODE>
3210 <DD>
3211 This matches the previous untranslated string including the string delimiters,
3212 the associated keywords (<CODE>msgid</CODE> etc.) and the spaces between them.
3213
3214 <DT><CODE>.msgid</CODE>
3215 <DD>
3216 This matches the untranslated string including the string delimiters,
3217 the associated keywords (<CODE>msgid</CODE> etc.) and the spaces between them.
3218
3219 <DT><CODE>.msgstr</CODE>
3220 <DD>
3221 This matches the translated string including the string delimiters,
3222 the associated keywords (<CODE>msgstr</CODE> etc.) and the spaces between them.
3223
3224 <DT><CODE>.keyword</CODE>
3225 <DD>
3226 This matches the keywords (<CODE>msgid</CODE>, <CODE>msgstr</CODE>, etc.).
3227
3228 <DT><CODE>.string</CODE>
3229 <DD>
3230 This matches strings, including the string delimiters (double quotes).
3231 </DL>
3232
3233 <LI>
3234
3235 Selectors that apply to parts of strings:
3236
3237 <DL COMPACT>
3238
3239 <DT><CODE>.text</CODE>
3240 <DD>
3241 This matches the entire contents of a string (excluding the string delimiters,
3242 i.e. the double quotes).
3243
3244 <DT><CODE>.escape-sequence</CODE>
3245 <DD>
3246 This matches an escape sequence (starting with a backslash).
3247
3248 <DT><CODE>.format-directive</CODE>
3249 <DD>
3250 This matches a format string directive (starting with a <SAMP>&lsquo;%&rsquo;</SAMP> sign in the
3251 case of most programming languages, with a <SAMP>&lsquo;{&rsquo;</SAMP> in the case of
3252 <CODE>java-format</CODE> and <CODE>csharp-format</CODE>, with a <SAMP>&lsquo;~&rsquo;</SAMP> in the case of
3253 <CODE>lisp-format</CODE> and <CODE>scheme-format</CODE>, or with <SAMP>&lsquo;$&rsquo;</SAMP> in the case of
3254 <CODE>sh-format</CODE>).
3255
3256 <DT><CODE>.invalid-format-directive</CODE>
3257 <DD>
3258 This matches an invalid format string directive.
3259
3260 <DT><CODE>.added</CODE>
3261 <DD>
3262 In an untranslated string, this matches a part of the string that was not
3263 present in the previous untranslated string.  (Not yet implemented in this
3264 release.)
3265
3266 <DT><CODE>.changed</CODE>
3267 <DD>
3268 In an untranslated string or in a previous untranslated string, this matches
3269 a part of the string that is changed or replaced.  (Not yet implemented in
3270 this release.)
3271
3272 <DT><CODE>.removed</CODE>
3273 <DD>
3274 In a previous untranslated string, this matches a part of the string that
3275 is not present in the current untranslated string.  (Not yet implemented in
3276 this release.)
3277 </DL>
3278 </UL>
3279
3280 <P>
3281 These selectors can be combined to hierarchical selectors.  For example,
3282
3283 </P>
3284
3285 <PRE>
3286 .msgstr .invalid-format-directive { color: red; }
3287 </PRE>
3288
3289 <P>
3290 will highlight the invalid format directives in the translated strings.
3291
3292 </P>
3293 <P>
3294 In text mode, pseudo-classes (CSS2 spec, section 5.11) and pseudo-elements
3295 (CSS2 spec, section 5.12) are not supported.
3296
3297 </P>
3298 <P>
3299 The declarations in HTML mode are not limited; any graphical attribute
3300 supported by the browsers can be used.
3301
3302 </P>
3303 <P>
3304 The declarations in text mode are limited to the following properties.  Other
3305 properties will be silently ignored.
3306
3307 </P>
3308 <DL COMPACT>
3309
3310 <DT><CODE>color</CODE> (CSS2 spec, section 14.1)
3311 <DD>
3312 <DT><CODE>background-color</CODE> (CSS2 spec, section 14.2.1)
3313 <DD>
3314 These properties is supported.  Colors will be adjusted to match the terminal's
3315 capabilities.  Note that many terminals support only 8 colors.
3316
3317 <DT><CODE>font-weight</CODE> (CSS2 spec, section 15.2.3)
3318 <DD>
3319 This property is supported, but most terminals can only render two different
3320 weights: <CODE>normal</CODE> and <CODE>bold</CODE>.  Values &#62;= 600 are rendered as
3321 <CODE>bold</CODE>.
3322
3323 <DT><CODE>font-style</CODE> (CSS2 spec, section 15.2.3)
3324 <DD>
3325 This property is supported.  The values <CODE>italic</CODE> and <CODE>oblique</CODE> are
3326 rendered the same way.
3327
3328 <DT><CODE>text-decoration</CODE> (CSS2 spec, section 16.3.1)
3329 <DD>
3330 This property is supported, limited to the values <CODE>none</CODE> and
3331 <CODE>underline</CODE>.
3332 </DL>
3333
3334
3335
3336 <H3><A NAME="SEC154" HREF="gettext_toc.html#TOC154">9.11.5  Customizing <CODE>less</CODE> for viewing PO files</A></H3>
3337
3338 <P>
3339 The <SAMP>&lsquo;less&rsquo;</SAMP> program is a popular text file browser for use in a text
3340 screen or terminal emulator.  It also supports text with embedded escape
3341 sequences for colors and text decorations.
3342
3343 </P>
3344 <P>
3345 You can use <CODE>less</CODE> to view a PO file like this (assuming an UTF-8
3346 environment):
3347
3348 </P>
3349
3350 <PRE>
3351 msgcat --to-code=UTF-8 --color xyz.po | less -R
3352 </PRE>
3353
3354 <P>
3355 You can simplify this to this simple command:
3356
3357 </P>
3358
3359 <PRE>
3360 less xyz.po
3361 </PRE>
3362
3363 <P>
3364 after these three preparations:
3365
3366 </P>
3367
3368 <OL>
3369 <LI>
3370
3371 Add the options <SAMP>&lsquo;-R&rsquo;</SAMP> and <SAMP>&lsquo;-f&rsquo;</SAMP> to the <CODE>LESS</CODE> environment
3372 variable.  In sh shells:
3373
3374 <PRE>
3375 $ LESS="$LESS -R -f"
3376 $ export LESS
3377 </PRE>
3378
3379 <LI>
3380
3381 If your system does not already have the <TT>&lsquo;lessopen.sh&rsquo;</TT> and
3382 <TT>&lsquo;lessclose.sh&rsquo;</TT> scripts, create them and set the <CODE>LESSOPEN</CODE> and
3383 <CODE>LESSCLOSE</CODE> environment variables, as indicated in the manual page
3384 (<SAMP>&lsquo;man less&rsquo;</SAMP>).
3385
3386 <LI>
3387
3388 Add to <TT>&lsquo;lessopen.sh&rsquo;</TT> a piece of script that recognizes PO files
3389 through their file extension and invokes <CODE>msgcat</CODE> on them, producing
3390 a temporary file.  Like this:
3391
3392
3393 <PRE>
3394 case "$1" in
3395   *.po)
3396     tmpfile=`mktemp "${TMPDIR-/tmp}/less.XXXXXX"`
3397     msgcat --to-code=UTF-8 --color "$1" &#62; "$tmpfile"
3398     echo "$tmpfile"
3399     exit 0
3400     ;;
3401 esac
3402 </PRE>
3403
3404 </OL>
3405
3406
3407
3408 <H2><A NAME="SEC155" HREF="gettext_toc.html#TOC155">9.12  Writing your own programs that process PO files</A></H2>
3409
3410 <P>
3411 For the tasks for which a combination of <SAMP>&lsquo;msgattrib&rsquo;</SAMP>, <SAMP>&lsquo;msgcat&rsquo;</SAMP> etc.
3412 is not sufficient, a set of C functions is provided in a library, to make it
3413 possible to process PO files in your own programs.  When you use this library,
3414 you don't need to write routines to parse the PO file; instead, you retrieve
3415 a pointer in memory to each of messages contained in the PO file.  Functions
3416 for writing PO files are not provided at this time.
3417
3418 </P>
3419 <P>
3420 The functions are declared in the header file <SAMP>&lsquo;&#60;gettext-po.h&#62;&rsquo;</SAMP>, and are
3421 defined in a library called <SAMP>&lsquo;libgettextpo&rsquo;</SAMP>.
3422
3423 </P>
3424 <P>
3425 <DL>
3426 <DT><U>Data Type:</U> <B>po_file_t</B>
3427 <DD><A NAME="IDX962"></A>
3428 This is a pointer type that refers to the contents of a PO file, after it has
3429 been read into memory.
3430 </DL>
3431
3432 </P>
3433 <P>
3434 <DL>
3435 <DT><U>Data Type:</U> <B>po_message_iterator_t</B>
3436 <DD><A NAME="IDX963"></A>
3437 This is a pointer type that refers to an iterator that produces a sequence of
3438 messages.
3439 </DL>
3440
3441 </P>
3442 <P>
3443 <DL>
3444 <DT><U>Data Type:</U> <B>po_message_t</B>
3445 <DD><A NAME="IDX964"></A>
3446 This is a pointer type that refers to a message of a PO file, including its
3447 translation.
3448 </DL>
3449
3450 </P>
3451 <P>
3452 <DL>
3453 <DT><U>Function:</U> po_file_t <B>po_file_read</B> <I>(const char *<VAR>filename</VAR>)</I>
3454 <DD><A NAME="IDX965"></A>
3455 The <CODE>po_file_read</CODE> function reads a PO file into memory.  The file name
3456 is given as argument.  The return value is a handle to the PO file's contents,
3457 valid until <CODE>po_file_free</CODE> is called on it.  In case of error, the return
3458 value is <CODE>NULL</CODE>, and <CODE>errno</CODE> is set.
3459 </DL>
3460
3461 </P>
3462 <P>
3463 <DL>
3464 <DT><U>Function:</U> void <B>po_file_free</B> <I>(po_file_t <VAR>file</VAR>)</I>
3465 <DD><A NAME="IDX966"></A>
3466 The <CODE>po_file_free</CODE> function frees a PO file's contents from memory,
3467 including all messages that are only implicitly accessible through iterators.
3468 </DL>
3469
3470 </P>
3471 <P>
3472 <DL>
3473 <DT><U>Function:</U> const char * const * <B>po_file_domains</B> <I>(po_file_t <VAR>file</VAR>)</I>
3474 <DD><A NAME="IDX967"></A>
3475 The <CODE>po_file_domains</CODE> function returns the domains for which the given
3476 PO file has messages.  The return value is a <CODE>NULL</CODE> terminated array
3477 which is valid as long as the <VAR>file</VAR> handle is valid.  For PO files which
3478 contain no <SAMP>&lsquo;domain&rsquo;</SAMP> directive, the return value contains only one domain,
3479 namely the default domain <CODE>"messages"</CODE>.
3480 </DL>
3481
3482 </P>
3483 <P>
3484 <DL>
3485 <DT><U>Function:</U> po_message_iterator_t <B>po_message_iterator</B> <I>(po_file_t <VAR>file</VAR>, const char *<VAR>domain</VAR>)</I>
3486 <DD><A NAME="IDX968"></A>
3487 The <CODE>po_message_iterator</CODE> returns an iterator that will produce the
3488 messages of <VAR>file</VAR> that belong to the given <VAR>domain</VAR>.  If <VAR>domain</VAR>
3489 is <CODE>NULL</CODE>, the default domain is used instead.  To list the messages,
3490 use the function <CODE>po_next_message</CODE> repeatedly.
3491 </DL>
3492
3493 </P>
3494 <P>
3495 <DL>
3496 <DT><U>Function:</U> void <B>po_message_iterator_free</B> <I>(po_message_iterator_t <VAR>iterator</VAR>)</I>
3497 <DD><A NAME="IDX969"></A>
3498 The <CODE>po_message_iterator_free</CODE> function frees an iterator previously
3499 allocated through the <CODE>po_message_iterator</CODE> function.
3500 </DL>
3501
3502 </P>
3503 <P>
3504 <DL>
3505 <DT><U>Function:</U> po_message_t <B>po_next_message</B> <I>(po_message_iterator_t <VAR>iterator</VAR>)</I>
3506 <DD><A NAME="IDX970"></A>
3507 The <CODE>po_next_message</CODE> function returns the next message from
3508 <VAR>iterator</VAR> and advances the iterator.  It returns <CODE>NULL</CODE> when the
3509 iterator has reached the end of its message list.
3510 </DL>
3511
3512 </P>
3513 <P>
3514 The following functions returns details of a <CODE>po_message_t</CODE>.  Recall
3515 that the results are valid as long as the <VAR>file</VAR> handle is valid.
3516
3517 </P>
3518 <P>
3519 <DL>
3520 <DT><U>Function:</U> const char * <B>po_message_msgid</B> <I>(po_message_t <VAR>message</VAR>)</I>
3521 <DD><A NAME="IDX971"></A>
3522 The <CODE>po_message_msgid</CODE> function returns the <CODE>msgid</CODE> (untranslated
3523 English string) of a message.  This is guaranteed to be non-<CODE>NULL</CODE>.
3524 </DL>
3525
3526 </P>
3527 <P>
3528 <DL>
3529 <DT><U>Function:</U> const char * <B>po_message_msgid_plural</B> <I>(po_message_t <VAR>message</VAR>)</I>
3530 <DD><A NAME="IDX972"></A>
3531 The <CODE>po_message_msgid_plural</CODE> function returns the <CODE>msgid_plural</CODE>
3532 (untranslated English plural string) of a message with plurals, or <CODE>NULL</CODE>
3533 for a message without plural.
3534 </DL>
3535
3536 </P>
3537 <P>
3538 <DL>
3539 <DT><U>Function:</U> const char * <B>po_message_msgstr</B> <I>(po_message_t <VAR>message</VAR>)</I>
3540 <DD><A NAME="IDX973"></A>
3541 The <CODE>po_message_msgstr</CODE> function returns the <CODE>msgstr</CODE> (translation)
3542 of a message.  For an untranslated message, the return value is an empty
3543 string.
3544 </DL>
3545
3546 </P>
3547 <P>
3548 <DL>
3549 <DT><U>Function:</U> const char * <B>po_message_msgstr_plural</B> <I>(po_message_t <VAR>message</VAR>, int <VAR>index</VAR>)</I>
3550 <DD><A NAME="IDX974"></A>
3551 The <CODE>po_message_msgstr_plural</CODE> function returns the
3552 <CODE>msgstr[<VAR>index</VAR>]</CODE> of a message with plurals, or <CODE>NULL</CODE> when
3553 the <VAR>index</VAR> is out of range or for a message without plural.
3554 </DL>
3555
3556 </P>
3557 <P>
3558 Here is an example code how these functions can be used.
3559
3560 </P>
3561
3562 <PRE>
3563 const char *filename = ...;
3564 po_file_t file = po_file_read (filename);
3565
3566 if (file == NULL)
3567   error (EXIT_FAILURE, errno, "couldn't open the PO file %s", filename);
3568 {
3569   const char * const *domains = po_file_domains (file);
3570   const char * const *domainp;
3571
3572   for (domainp = domains; *domainp; domainp++)
3573     {
3574       const char *domain = *domainp;
3575       po_message_iterator_t iterator = po_message_iterator (file, domain);
3576
3577       for (;;)
3578         {
3579           po_message_t *message = po_next_message (iterator);
3580
3581           if (message == NULL)
3582             break;
3583           {
3584             const char *msgid = po_message_msgid (message);
3585             const char *msgstr = po_message_msgstr (message);
3586
3587             ...
3588           }
3589         }
3590       po_message_iterator_free (iterator);
3591     }
3592 }
3593 po_file_free (file);
3594 </PRE>
3595
3596 <P><HR><P>
3597 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_8.html">previous</A>, <A HREF="gettext_10.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
3598 </BODY>
3599 </HTML>