Add -lm dependency for gettextlib to fix LTO build
[platform/upstream/gettext.git] / gettext-tools / doc / gettext_10.html
1 <HTML>
2 <HEAD>
3 <!-- This HTML file has been created by texi2html 1.52b
4      from gettext.texi on 28 December 2015 -->
5
6 <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
7 <TITLE>GNU gettext utilities - 10  Producing Binary MO Files</TITLE>
8 </HEAD>
9 <BODY>
10 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_9.html">previous</A>, <A HREF="gettext_11.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="SEC156" HREF="gettext_toc.html#TOC156">10  Producing Binary MO Files</A></H1>
15
16
17
18 <H2><A NAME="SEC157" HREF="gettext_toc.html#TOC157">10.1  Invoking the <CODE>msgfmt</CODE> Program</A></H2>
19
20 <P>
21 <A NAME="IDX975"></A>
22 <A NAME="IDX976"></A>
23
24 <PRE>
25 msgfmt [<VAR>option</VAR>] <VAR>filename</VAR>.po ...
26 </PRE>
27
28 <P>
29 <A NAME="IDX977"></A>
30 The <CODE>msgfmt</CODE> programs generates a binary message catalog from a textual
31 translation description.
32
33 </P>
34
35
36 <H3><A NAME="SEC158" HREF="gettext_toc.html#TOC158">10.1.1  Input file location</A></H3>
37
38 <DL COMPACT>
39
40 <DT><SAMP>&lsquo;<VAR>filename</VAR>.po ...&rsquo;</SAMP>
41 <DD>
42 <DT><SAMP>&lsquo;-D <VAR>directory</VAR>&rsquo;</SAMP>
43 <DD>
44 <DT><SAMP>&lsquo;--directory=<VAR>directory</VAR>&rsquo;</SAMP>
45 <DD>
46 <A NAME="IDX978"></A>
47 <A NAME="IDX979"></A>
48 Add <VAR>directory</VAR> to the list of directories.  Source files are
49 searched relative to this list of directories.  The resulting binary
50 file will be written relative to the current directory, though.
51
52 </DL>
53
54 <P>
55 If an input file is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
56
57 </P>
58
59
60 <H3><A NAME="SEC159" HREF="gettext_toc.html#TOC159">10.1.2  Operation mode</A></H3>
61
62 <DL COMPACT>
63
64 <DT><SAMP>&lsquo;-j&rsquo;</SAMP>
65 <DD>
66 <DT><SAMP>&lsquo;--java&rsquo;</SAMP>
67 <DD>
68 <A NAME="IDX980"></A>
69 <A NAME="IDX981"></A>
70 <A NAME="IDX982"></A>
71 Java mode: generate a Java <CODE>ResourceBundle</CODE> class.
72
73 <DT><SAMP>&lsquo;--java2&rsquo;</SAMP>
74 <DD>
75 <A NAME="IDX983"></A>
76 Like --java, and assume Java2 (JDK 1.2 or higher).
77
78 <DT><SAMP>&lsquo;--csharp&rsquo;</SAMP>
79 <DD>
80 <A NAME="IDX984"></A>
81 <A NAME="IDX985"></A>
82 C# mode: generate a .NET .dll file containing a subclass of
83 <CODE>GettextResourceSet</CODE>.
84
85 <DT><SAMP>&lsquo;--csharp-resources&rsquo;</SAMP>
86 <DD>
87 <A NAME="IDX986"></A>
88 <A NAME="IDX987"></A>
89 C# resources mode: generate a .NET <TT>&lsquo;.resources&rsquo;</TT> file.
90
91 <DT><SAMP>&lsquo;--tcl&rsquo;</SAMP>
92 <DD>
93 <A NAME="IDX988"></A>
94 <A NAME="IDX989"></A>
95 Tcl mode: generate a tcl/msgcat <TT>&lsquo;.msg&rsquo;</TT> file.
96
97 <DT><SAMP>&lsquo;--qt&rsquo;</SAMP>
98 <DD>
99 <A NAME="IDX990"></A>
100 <A NAME="IDX991"></A>
101 Qt mode: generate a Qt <TT>&lsquo;.qm&rsquo;</TT> file.
102
103 <DT><SAMP>&lsquo;--desktop&rsquo;</SAMP>
104 <DD>
105 <A NAME="IDX992"></A>
106 <A NAME="IDX993"></A>
107 Desktop Entry mode: generate a <TT>&lsquo;.desktop&rsquo;</TT> file.
108
109 <DT><SAMP>&lsquo;--xml&rsquo;</SAMP>
110 <DD>
111 <A NAME="IDX994"></A>
112 <A NAME="IDX995"></A>
113 XML mode: generate an XML file.
114
115 </DL>
116
117
118
119 <H3><A NAME="SEC160" HREF="gettext_toc.html#TOC160">10.1.3  Output file location</A></H3>
120
121 <DL COMPACT>
122
123 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
124 <DD>
125 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
126 <DD>
127 <A NAME="IDX996"></A>
128 <A NAME="IDX997"></A>
129 Write output to specified file.
130
131 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
132 <DD>
133 <A NAME="IDX998"></A>
134 Direct the program to work strictly following the Uniforum/Sun
135 implementation.  Currently this only affects the naming of the output
136 file.  If this option is not given the name of the output file is the
137 same as the domain name.  If the strict Uniforum mode is enabled the
138 suffix <TT>&lsquo;.mo&rsquo;</TT> is added to the file name if it is not already
139 present.
140
141 We find this behaviour of Sun's implementation rather silly and so by
142 default this mode is <EM>not</EM> selected.
143
144 </DL>
145
146 <P>
147 If the output <VAR>file</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, output is written to standard output.
148
149 </P>
150
151
152 <H3><A NAME="SEC161" HREF="gettext_toc.html#TOC161">10.1.4  Output file location in Java mode</A></H3>
153
154 <DL COMPACT>
155
156 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
157 <DD>
158 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
159 <DD>
160 <A NAME="IDX999"></A>
161 <A NAME="IDX1000"></A>
162 Specify the resource name.
163
164 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
165 <DD>
166 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
167 <DD>
168 <A NAME="IDX1001"></A>
169 <A NAME="IDX1002"></A>
170 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
171 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
172
173 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
174 <DD>
175 <A NAME="IDX1003"></A>
176 Specify the base directory of classes directory hierarchy.
177
178 <DT><SAMP>&lsquo;--source&rsquo;</SAMP>
179 <DD>
180 <A NAME="IDX1004"></A>
181 Produce a .java source file, instead of a compiled .class file.
182
183 </DL>
184
185 <P>
186 The class name is determined by appending the locale name to the resource name,
187 separated with an underscore.  The <SAMP>&lsquo;-d&rsquo;</SAMP> option is mandatory.  The class
188 is written under the specified directory.
189
190 </P>
191
192
193 <H3><A NAME="SEC162" HREF="gettext_toc.html#TOC162">10.1.5  Output file location in C# mode</A></H3>
194
195 <DL COMPACT>
196
197 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
198 <DD>
199 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
200 <DD>
201 <A NAME="IDX1005"></A>
202 <A NAME="IDX1006"></A>
203 Specify the resource name.
204
205 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
206 <DD>
207 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
208 <DD>
209 <A NAME="IDX1007"></A>
210 <A NAME="IDX1008"></A>
211 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
212 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
213
214 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
215 <DD>
216 <A NAME="IDX1009"></A>
217 Specify the base directory for locale dependent <TT>&lsquo;.dll&rsquo;</TT> files.
218
219 </DL>
220
221 <P>
222 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.dll&rsquo;</TT> file is
223 written in a subdirectory of the specified directory whose name depends on the
224 locale.
225
226 </P>
227
228
229 <H3><A NAME="SEC163" HREF="gettext_toc.html#TOC163">10.1.6  Output file location in Tcl mode</A></H3>
230
231 <DL COMPACT>
232
233 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
234 <DD>
235 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
236 <DD>
237 <A NAME="IDX1010"></A>
238 <A NAME="IDX1011"></A>
239 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
240 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
241
242 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
243 <DD>
244 <A NAME="IDX1012"></A>
245 Specify the base directory of <TT>&lsquo;.msg&rsquo;</TT> message catalogs.
246
247 </DL>
248
249 <P>
250 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
251 written in the specified directory.
252
253 </P>
254
255
256 <H3><A NAME="SEC164" HREF="gettext_toc.html#TOC164">10.1.7  Desktop Entry mode operations</A></H3>
257
258 <DL COMPACT>
259
260 <DT><SAMP>&lsquo;--template=<VAR>template</VAR>&rsquo;</SAMP>
261 <DD>
262 <A NAME="IDX1013"></A>
263 Specify a .desktop file used as a template.
264
265 <DT><SAMP>&lsquo;-k[<VAR>keywordspec</VAR>]&rsquo;</SAMP>
266 <DD>
267 <DT><SAMP>&lsquo;--keyword[=<VAR>keywordspec</VAR>]&rsquo;</SAMP>
268 <DD>
269 <A NAME="IDX1014"></A>
270 <A NAME="IDX1015"></A>
271 Specify <VAR>keywordspec</VAR> as an additional keyword to be looked for.
272 Without a <VAR>keywordspec</VAR>, the option means to not use default keywords.
273
274 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
275 <DD>
276 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
277 <DD>
278 <A NAME="IDX1016"></A>
279 <A NAME="IDX1017"></A>
280 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
281 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
282
283 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
284 <DD>
285 <A NAME="IDX1018"></A>
286 Specify the directory where PO files are read.  The directory must
287 contain the <SAMP>&lsquo;LINGUAS&rsquo;</SAMP> file.
288
289 </DL>
290
291 <P>
292 To generate a <SAMP>&lsquo;.desktop&rsquo;</SAMP> file for a single locale, you can use it
293 as follows.
294
295 </P>
296
297 <PRE>
298 msgfmt --desktop --template=<VAR>template</VAR> --locale=<VAR>locale</VAR> \
299   -o <VAR>file</VAR> <VAR>filename</VAR>.po ...
300 </PRE>
301
302 <P>
303 msgfmt provides a special "bulk" operation mode to process multiple
304 <TT>&lsquo;.po&rsquo;</TT> files at a time.
305
306 </P>
307
308 <PRE>
309 msgfmt --desktop --template=<VAR>template</VAR> -d <VAR>directory</VAR> -o <VAR>file</VAR>
310 </PRE>
311
312 <P>
313 msgfmt first reads the <SAMP>&lsquo;LINGUAS&rsquo;</SAMP> file under <VAR>directory</VAR>, and
314 then processes all <SAMP>&lsquo;.po&rsquo;</SAMP> files listed there.  You can also limit
315 the locales to a subset, through the <SAMP>&lsquo;LINGUAS&rsquo;</SAMP> environment
316 variable.
317
318 </P>
319 <P>
320 For either operation modes, the <SAMP>&lsquo;-o&rsquo;</SAMP> and <SAMP>&lsquo;--template&rsquo;</SAMP>
321 options are mandatory.
322
323 </P>
324
325
326 <H3><A NAME="SEC165" HREF="gettext_toc.html#TOC165">10.1.8  XML mode operations</A></H3>
327
328 <DL COMPACT>
329
330 <DT><SAMP>&lsquo;--template=<VAR>template</VAR>&rsquo;</SAMP>
331 <DD>
332 <A NAME="IDX1019"></A>
333 Specify an XML file used as a template.
334
335 <DT><SAMP>&lsquo;-L <VAR>name</VAR>&rsquo;</SAMP>
336 <DD>
337 <DT><SAMP>&lsquo;--language=<VAR>name</VAR>&rsquo;</SAMP>
338 <DD>
339 <A NAME="IDX1020"></A>
340 <A NAME="IDX1021"></A>
341 <A NAME="IDX1022"></A>
342 Specifies the language of the input files.
343
344 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
345 <DD>
346 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
347 <DD>
348 <A NAME="IDX1023"></A>
349 <A NAME="IDX1024"></A>
350 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
351 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
352
353 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
354 <DD>
355 <A NAME="IDX1025"></A>
356 Specify the base directory of <TT>&lsquo;.po&rsquo;</TT> message catalogs.
357
358 </DL>
359
360 <P>
361 To generate an XML file for a single locale, you can use it as follows.
362
363 </P>
364
365 <PRE>
366 msgfmt --xml --template=<VAR>template</VAR> --locale=<VAR>locale</VAR> \
367   -o <VAR>file</VAR> <VAR>filename</VAR>.po ...
368 </PRE>
369
370 <P>
371 msgfmt provides a special "bulk" operation mode to process multiple
372 <TT>&lsquo;.po&rsquo;</TT> files at a time.
373
374 </P>
375
376 <PRE>
377 msgfmt --xml --template=<VAR>template</VAR> -d <VAR>directory</VAR> -o <VAR>file</VAR>
378 </PRE>
379
380 <P>
381 msgfmt first reads the <SAMP>&lsquo;LINGUAS&rsquo;</SAMP> file under <VAR>directory</VAR>, and
382 then processes all <SAMP>&lsquo;.po&rsquo;</SAMP> files listed there.  You can also limit
383 the locales to a subset, through the <SAMP>&lsquo;LINGUAS&rsquo;</SAMP> environment
384 variable.
385
386 </P>
387 <P>
388 For either operation modes, the <SAMP>&lsquo;-o&rsquo;</SAMP> and <SAMP>&lsquo;--template&rsquo;</SAMP>
389 options are mandatory.
390
391 </P>
392
393
394 <H3><A NAME="SEC166" HREF="gettext_toc.html#TOC166">10.1.9  Input file syntax</A></H3>
395
396 <DL COMPACT>
397
398 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
399 <DD>
400 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
401 <DD>
402 <A NAME="IDX1026"></A>
403 <A NAME="IDX1027"></A>
404 Assume the input files are Java ResourceBundles in Java <CODE>.properties</CODE>
405 syntax, not in PO file syntax.
406
407 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
408 <DD>
409 <A NAME="IDX1028"></A>
410 Assume the input files are NeXTstep/GNUstep localized resource files in
411 <CODE>.strings</CODE> syntax, not in PO file syntax.
412
413 </DL>
414
415
416
417 <H3><A NAME="SEC167" HREF="gettext_toc.html#TOC167">10.1.10  Input file interpretation</A></H3>
418
419 <DL COMPACT>
420
421 <DT><SAMP>&lsquo;-c&rsquo;</SAMP>
422 <DD>
423 <DT><SAMP>&lsquo;--check&rsquo;</SAMP>
424 <DD>
425 <A NAME="IDX1029"></A>
426 <A NAME="IDX1030"></A>
427 Perform all the checks implied by <CODE>--check-format</CODE>, <CODE>--check-header</CODE>,
428 <CODE>--check-domain</CODE>.
429
430 <DT><SAMP>&lsquo;--check-format&rsquo;</SAMP>
431 <DD>
432 <A NAME="IDX1031"></A>
433 <A NAME="IDX1032"></A>
434 Check language dependent format strings.
435
436 If the string represents a format string used in a
437 <CODE>printf</CODE>-like function both strings should have the same number of
438 <SAMP>&lsquo;%&rsquo;</SAMP> format specifiers, with matching types.  If the flag
439 <CODE>c-format</CODE> or <CODE>possible-c-format</CODE> appears in the special
440 comment <KBD>#,</KBD> for this entry a check is performed.  For example, the
441 check will diagnose using <SAMP>&lsquo;%.*s&rsquo;</SAMP> against <SAMP>&lsquo;%s&rsquo;</SAMP>, or <SAMP>&lsquo;%d&rsquo;</SAMP>
442 against <SAMP>&lsquo;%s&rsquo;</SAMP>, or <SAMP>&lsquo;%d&rsquo;</SAMP> against <SAMP>&lsquo;%x&rsquo;</SAMP>.  It can even handle
443 positional parameters.
444
445 Normally the <CODE>xgettext</CODE> program automatically decides whether a
446 string is a format string or not.  This algorithm is not perfect,
447 though.  It might regard a string as a format string though it is not
448 used in a <CODE>printf</CODE>-like function and so <CODE>msgfmt</CODE> might report
449 errors where there are none.
450
451 To solve this problem the programmer can dictate the decision to the
452 <CODE>xgettext</CODE> program (see section <A HREF="gettext_15.html#SEC252">15.3.1  C Format Strings</A>).  The translator should not
453 consider removing the flag from the <KBD>#,</KBD> line.  This "fix" would be
454 reversed again as soon as <CODE>msgmerge</CODE> is called the next time.
455
456 <DT><SAMP>&lsquo;--check-header&rsquo;</SAMP>
457 <DD>
458 <A NAME="IDX1033"></A>
459 Verify presence and contents of the header entry.  See section <A HREF="gettext_6.html#SEC44">6.2  Filling in the Header Entry</A>,
460 for a description of the various fields in the header entry.
461
462 <DT><SAMP>&lsquo;--check-domain&rsquo;</SAMP>
463 <DD>
464 <A NAME="IDX1034"></A>
465 Check for conflicts between domain directives and the <CODE>--output-file</CODE>
466 option
467
468 <DT><SAMP>&lsquo;-C&rsquo;</SAMP>
469 <DD>
470 <DT><SAMP>&lsquo;--check-compatibility&rsquo;</SAMP>
471 <DD>
472 <A NAME="IDX1035"></A>
473 <A NAME="IDX1036"></A>
474 <A NAME="IDX1037"></A>
475 Check that GNU msgfmt behaves like X/Open msgfmt.  This will give an error
476 when attempting to use the GNU extensions.
477
478 <DT><SAMP>&lsquo;--check-accelerators[=<VAR>char</VAR>]&rsquo;</SAMP>
479 <DD>
480 <A NAME="IDX1038"></A>
481 <A NAME="IDX1039"></A>
482 <A NAME="IDX1040"></A>
483 <A NAME="IDX1041"></A>
484 Check presence of keyboard accelerators for menu items.  This is based on
485 the convention used in some GUIs that a keyboard accelerator in a menu
486 item string is designated by an immediately preceding <SAMP>&lsquo;&#38;&rsquo;</SAMP> character.
487 Sometimes a keyboard accelerator is also called "keyboard mnemonic".
488 This check verifies that if the untranslated string has exactly one
489 <SAMP>&lsquo;&#38;&rsquo;</SAMP> character, the translated string has exactly one <SAMP>&lsquo;&#38;&rsquo;</SAMP> as well.
490 If this option is given with a <VAR>char</VAR> argument, this <VAR>char</VAR> should
491 be a non-alphanumeric character and is used as keyboard accelerator mark
492 instead of <SAMP>&lsquo;&#38;&rsquo;</SAMP>.
493
494 <DT><SAMP>&lsquo;-f&rsquo;</SAMP>
495 <DD>
496 <DT><SAMP>&lsquo;--use-fuzzy&rsquo;</SAMP>
497 <DD>
498 <A NAME="IDX1042"></A>
499 <A NAME="IDX1043"></A>
500 <A NAME="IDX1044"></A>
501 Use fuzzy entries in output.  Note that using this option is usually wrong,
502 because fuzzy messages are exactly those which have not been validated by
503 a human translator.
504
505 </DL>
506
507
508
509 <H3><A NAME="SEC168" HREF="gettext_toc.html#TOC168">10.1.11  Output details</A></H3>
510
511 <DL COMPACT>
512
513 <DT><SAMP>&lsquo;-a <VAR>number</VAR>&rsquo;</SAMP>
514 <DD>
515 <DT><SAMP>&lsquo;--alignment=<VAR>number</VAR>&rsquo;</SAMP>
516 <DD>
517 <A NAME="IDX1045"></A>
518 <A NAME="IDX1046"></A>
519 Align strings to <VAR>number</VAR> bytes (default: 1).
520
521 <DT><SAMP>&lsquo;--endianness=<VAR>byteorder</VAR>&rsquo;</SAMP>
522 <DD>
523 <A NAME="IDX1047"></A>
524 Write out 32-bit numbers in the given byte order.  The possible values are
525 <CODE>big</CODE> and <CODE>little</CODE>.  The default depends on the platform, namely
526 on the endianness of the CPU.
527
528 MO files of any endianness can be used on any platform.  When a MO file has
529 an endianness other than the platform's one, the 32-bit numbers from the MO
530 file are swapped at runtime.  The performance impact is negligible.
531
532 This option can be useful to produce MO files that are independent of the
533 platform.
534
535 <DT><SAMP>&lsquo;--no-hash&rsquo;</SAMP>
536 <DD>
537 <A NAME="IDX1048"></A>
538 Don't include a hash table in the binary file.  Lookup will be more expensive
539 at run time (binary search instead of hash table lookup).
540
541 </DL>
542
543
544
545 <H3><A NAME="SEC169" HREF="gettext_toc.html#TOC169">10.1.12  Informative output</A></H3>
546
547 <DL COMPACT>
548
549 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
550 <DD>
551 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
552 <DD>
553 <A NAME="IDX1049"></A>
554 <A NAME="IDX1050"></A>
555 Display this help and exit.
556
557 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
558 <DD>
559 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
560 <DD>
561 <A NAME="IDX1051"></A>
562 <A NAME="IDX1052"></A>
563 Output version information and exit.
564
565 <DT><SAMP>&lsquo;--statistics&rsquo;</SAMP>
566 <DD>
567 <A NAME="IDX1053"></A>
568 Print statistics about translations.  When the option <CODE>--verbose</CODE> is used
569 in combination with <CODE>--statistics</CODE>, the input file name is printed in
570 front of the statistics line.
571
572 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
573 <DD>
574 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
575 <DD>
576 <A NAME="IDX1054"></A>
577 <A NAME="IDX1055"></A>
578 Increase verbosity level.
579
580 </DL>
581
582
583
584 <H2><A NAME="SEC170" HREF="gettext_toc.html#TOC170">10.2  Invoking the <CODE>msgunfmt</CODE> Program</A></H2>
585
586 <P>
587 <A NAME="IDX1056"></A>
588 <A NAME="IDX1057"></A>
589
590 <PRE>
591 msgunfmt [<VAR>option</VAR>] [<VAR>file</VAR>]...
592 </PRE>
593
594 <P>
595 <A NAME="IDX1058"></A>
596 The <CODE>msgunfmt</CODE> program converts a binary message catalog to a
597 Uniforum style .po file.
598
599 </P>
600
601
602 <H3><A NAME="SEC171" HREF="gettext_toc.html#TOC171">10.2.1  Operation mode</A></H3>
603
604 <DL COMPACT>
605
606 <DT><SAMP>&lsquo;-j&rsquo;</SAMP>
607 <DD>
608 <DT><SAMP>&lsquo;--java&rsquo;</SAMP>
609 <DD>
610 <A NAME="IDX1059"></A>
611 <A NAME="IDX1060"></A>
612 <A NAME="IDX1061"></A>
613 Java mode: input is a Java <CODE>ResourceBundle</CODE> class.
614
615 <DT><SAMP>&lsquo;--csharp&rsquo;</SAMP>
616 <DD>
617 <A NAME="IDX1062"></A>
618 <A NAME="IDX1063"></A>
619 C# mode: input is a .NET .dll file containing a subclass of
620 <CODE>GettextResourceSet</CODE>.
621
622 <DT><SAMP>&lsquo;--csharp-resources&rsquo;</SAMP>
623 <DD>
624 <A NAME="IDX1064"></A>
625 <A NAME="IDX1065"></A>
626 C# resources mode: input is a .NET <TT>&lsquo;.resources&rsquo;</TT> file.
627
628 <DT><SAMP>&lsquo;--tcl&rsquo;</SAMP>
629 <DD>
630 <A NAME="IDX1066"></A>
631 <A NAME="IDX1067"></A>
632 Tcl mode: input is a tcl/msgcat <TT>&lsquo;.msg&rsquo;</TT> file.
633
634 </DL>
635
636
637
638 <H3><A NAME="SEC172" HREF="gettext_toc.html#TOC172">10.2.2  Input file location</A></H3>
639
640 <DL COMPACT>
641
642 <DT><SAMP>&lsquo;<VAR>file</VAR> ...&rsquo;</SAMP>
643 <DD>
644 Input .mo files.
645
646 </DL>
647
648 <P>
649 If no input <VAR>file</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
650
651 </P>
652
653
654 <H3><A NAME="SEC173" HREF="gettext_toc.html#TOC173">10.2.3  Input file location in Java mode</A></H3>
655
656 <DL COMPACT>
657
658 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
659 <DD>
660 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
661 <DD>
662 <A NAME="IDX1068"></A>
663 <A NAME="IDX1069"></A>
664 Specify the resource name.
665
666 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
667 <DD>
668 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
669 <DD>
670 <A NAME="IDX1070"></A>
671 <A NAME="IDX1071"></A>
672 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
673 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
674
675 </DL>
676
677 <P>
678 The class name is determined by appending the locale name to the resource name,
679 separated with an underscore.  The class is located using the <CODE>CLASSPATH</CODE>.
680
681 </P>
682
683
684 <H3><A NAME="SEC174" HREF="gettext_toc.html#TOC174">10.2.4  Input file location in C# mode</A></H3>
685
686 <DL COMPACT>
687
688 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
689 <DD>
690 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
691 <DD>
692 <A NAME="IDX1072"></A>
693 <A NAME="IDX1073"></A>
694 Specify the resource name.
695
696 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
697 <DD>
698 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
699 <DD>
700 <A NAME="IDX1074"></A>
701 <A NAME="IDX1075"></A>
702 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
703 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
704
705 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
706 <DD>
707 <A NAME="IDX1076"></A>
708 Specify the base directory for locale dependent <TT>&lsquo;.dll&rsquo;</TT> files.
709
710 </DL>
711
712 <P>
713 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
714 located in a subdirectory of the specified directory whose name depends on the
715 locale.
716
717 </P>
718
719
720 <H3><A NAME="SEC175" HREF="gettext_toc.html#TOC175">10.2.5  Input file location in Tcl mode</A></H3>
721
722 <DL COMPACT>
723
724 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
725 <DD>
726 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
727 <DD>
728 <A NAME="IDX1077"></A>
729 <A NAME="IDX1078"></A>
730 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
731 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
732
733 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
734 <DD>
735 <A NAME="IDX1079"></A>
736 Specify the base directory of <TT>&lsquo;.msg&rsquo;</TT> message catalogs.
737
738 </DL>
739
740 <P>
741 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
742 located in the specified directory.
743
744 </P>
745
746
747 <H3><A NAME="SEC176" HREF="gettext_toc.html#TOC176">10.2.6  Output file location</A></H3>
748
749 <DL COMPACT>
750
751 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
752 <DD>
753 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
754 <DD>
755 <A NAME="IDX1080"></A>
756 <A NAME="IDX1081"></A>
757 Write output to specified file.
758
759 </DL>
760
761 <P>
762 The results are written to standard output if no output file is specified
763 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
764
765 </P>
766
767
768 <H3><A NAME="SEC177" HREF="gettext_toc.html#TOC177">10.2.7  Output details</A></H3>
769
770 <DL COMPACT>
771
772 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
773 <DD>
774 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
775 <DD>
776 <A NAME="IDX1082"></A>
777 Specify whether or when to use colors and other text attributes.
778 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
779
780 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
781 <DD>
782 <A NAME="IDX1083"></A>
783 Specify the CSS style rule file to use for <CODE>--color</CODE>.
784 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
785
786 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
787 <DD>
788 <A NAME="IDX1084"></A>
789 Always write an output file even if it contains no message.
790
791 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
792 <DD>
793 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
794 <DD>
795 <A NAME="IDX1085"></A>
796 <A NAME="IDX1086"></A>
797 Write the .po file using indented style.
798
799 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
800 <DD>
801 <A NAME="IDX1087"></A>
802 Write out a strict Uniforum conforming PO file.  Note that this
803 Uniforum format should be avoided because it doesn't support the
804 GNU extensions.
805
806 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
807 <DD>
808 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
809 <DD>
810 <A NAME="IDX1088"></A>
811 <A NAME="IDX1089"></A>
812 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
813 that this file format doesn't support plural forms and silently drops
814 obsolete messages.
815
816 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
817 <DD>
818 <A NAME="IDX1090"></A>
819 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
820 Note that this file format doesn't support plural forms.
821
822 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
823 <DD>
824 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
825 <DD>
826 <A NAME="IDX1091"></A>
827 <A NAME="IDX1092"></A>
828 Set the output page width.  Long strings in the output files will be
829 split across multiple lines in order to ensure that each line's width
830 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
831
832 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
833 <DD>
834 <A NAME="IDX1093"></A>
835 Do not break long message lines.  Message lines whose width exceeds the
836 output page width will not be split into several lines.  Only file reference
837 lines which are wider than the output page width will be split.
838
839 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
840 <DD>
841 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
842 <DD>
843 <A NAME="IDX1094"></A>
844 <A NAME="IDX1095"></A>
845 <A NAME="IDX1096"></A>
846 Generate sorted output.  Note that using this option makes it much harder
847 for the translator to understand each message's context.
848
849 </DL>
850
851
852
853 <H3><A NAME="SEC178" HREF="gettext_toc.html#TOC178">10.2.8  Informative output</A></H3>
854
855 <DL COMPACT>
856
857 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
858 <DD>
859 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
860 <DD>
861 <A NAME="IDX1097"></A>
862 <A NAME="IDX1098"></A>
863 Display this help and exit.
864
865 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
866 <DD>
867 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
868 <DD>
869 <A NAME="IDX1099"></A>
870 <A NAME="IDX1100"></A>
871 Output version information and exit.
872
873 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
874 <DD>
875 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
876 <DD>
877 <A NAME="IDX1101"></A>
878 <A NAME="IDX1102"></A>
879 Increase verbosity level.
880
881 </DL>
882
883
884
885 <H2><A NAME="SEC179" HREF="gettext_toc.html#TOC179">10.3  The Format of GNU MO Files</A></H2>
886 <P>
887 <A NAME="IDX1103"></A>
888 <A NAME="IDX1104"></A>
889
890 </P>
891 <P>
892 The format of the generated MO files is best described by a picture,
893 which appears below.
894
895 </P>
896 <P>
897 <A NAME="IDX1105"></A>
898 The first two words serve the identification of the file.  The magic
899 number will always signal GNU MO files.  The number is stored in the
900 byte order of the generating machine, so the magic number really is
901 two numbers: <CODE>0x950412de</CODE> and <CODE>0xde120495</CODE>.
902
903 </P>
904 <P>
905 The second word describes the current revision of the file format,
906 composed of a major and a minor revision number.  The revision numbers
907 ensure that the readers of MO files can distinguish new formats from
908 old ones and handle their contents, as far as possible.  For now the
909 major revision is 0 or 1, and the minor revision is also 0 or 1.  More
910 revisions might be added in the future.  A program seeing an unexpected
911 major revision number should stop reading the MO file entirely; whereas
912 an unexpected minor revision number means that the file can be read but
913 will not reveal its full contents, when parsed by a program that
914 supports only smaller minor revision numbers.
915
916 </P>
917 <P>
918 The version is kept
919 separate from the magic number, instead of using different magic
920 numbers for different formats, mainly because <TT>&lsquo;/etc/magic&rsquo;</TT> is
921 not updated often.
922
923 </P>
924 <P>
925 Follow a number of pointers to later tables in the file, allowing
926 for the extension of the prefix part of MO files without having to
927 recompile programs reading them.  This might become useful for later
928 inserting a few flag bits, indication about the charset used, new
929 tables, or other things.
930
931 </P>
932 <P>
933 Then, at offset <VAR>O</VAR> and offset <VAR>T</VAR> in the picture, two tables
934 of string descriptors can be found.  In both tables, each string
935 descriptor uses two 32 bits integers, one for the string length,
936 another for the offset of the string in the MO file, counting in bytes
937 from the start of the file.  The first table contains descriptors
938 for the original strings, and is sorted so the original strings
939 are in increasing lexicographical order.  The second table contains
940 descriptors for the translated strings, and is parallel to the first
941 table: to find the corresponding translation one has to access the
942 array slot in the second array with the same index.
943
944 </P>
945 <P>
946 Having the original strings sorted enables the use of simple binary
947 search, for when the MO file does not contain an hashing table, or
948 for when it is not practical to use the hashing table provided in
949 the MO file.  This also has another advantage, as the empty string
950 in a PO file GNU <CODE>gettext</CODE> is usually <EM>translated</EM> into
951 some system information attached to that particular MO file, and the
952 empty string necessarily becomes the first in both the original and
953 translated tables, making the system information very easy to find.
954
955 </P>
956 <P>
957 <A NAME="IDX1106"></A>
958 The size <VAR>S</VAR> of the hash table can be zero.  In this case, the
959 hash table itself is not contained in the MO file.  Some people might
960 prefer this because a precomputed hashing table takes disk space, and
961 does not win <EM>that</EM> much speed.  The hash table contains indices
962 to the sorted array of strings in the MO file.  Conflict resolution is
963 done by double hashing.  The precise hashing algorithm used is fairly
964 dependent on GNU <CODE>gettext</CODE> code, and is not documented here.
965
966 </P>
967 <P>
968 As for the strings themselves, they follow the hash file, and each
969 is terminated with a <KBD>NUL</KBD>, and this <KBD>NUL</KBD> is not counted in
970 the length which appears in the string descriptor.  The <CODE>msgfmt</CODE>
971 program has an option selecting the alignment for MO file strings.
972 With this option, each string is separately aligned so it starts at
973 an offset which is a multiple of the alignment value.  On some RISC
974 machines, a correct alignment will speed things up.
975
976 </P>
977 <P>
978 <A NAME="IDX1107"></A>
979 Contexts are stored by storing the concatenation of the context, a
980 <KBD>EOT</KBD> byte, and the original string, instead of the original string.
981
982 </P>
983 <P>
984 <A NAME="IDX1108"></A>
985 Plural forms are stored by letting the plural of the original string
986 follow the singular of the original string, separated through a
987 <KBD>NUL</KBD> byte.  The length which appears in the string descriptor
988 includes both.  However, only the singular of the original string
989 takes part in the hash table lookup.  The plural variants of the
990 translation are all stored consecutively, separated through a
991 <KBD>NUL</KBD> byte.  Here also, the length in the string descriptor
992 includes all of them.
993
994 </P>
995 <P>
996 Nothing prevents a MO file from having embedded <KBD>NUL</KBD>s in strings.
997 However, the program interface currently used already presumes
998 that strings are <KBD>NUL</KBD> terminated, so embedded <KBD>NUL</KBD>s are
999 somewhat useless.  But the MO file format is general enough so other
1000 interfaces would be later possible, if for example, we ever want to
1001 implement wide characters right in MO files, where <KBD>NUL</KBD> bytes may
1002 accidentally appear.  (No, we don't want to have wide characters in MO
1003 files.  They would make the file unnecessarily large, and the
1004 <SAMP>&lsquo;wchar_t&rsquo;</SAMP> type being platform dependent, MO files would be
1005 platform dependent as well.)
1006
1007 </P>
1008 <P>
1009 This particular issue has been strongly debated in the GNU
1010 <CODE>gettext</CODE> development forum, and it is expectable that MO file
1011 format will evolve or change over time.  It is even possible that many
1012 formats may later be supported concurrently.  But surely, we have to
1013 start somewhere, and the MO file format described here is a good start.
1014 Nothing is cast in concrete, and the format may later evolve fairly
1015 easily, so we should feel comfortable with the current approach.
1016
1017 </P>
1018
1019 <PRE>
1020         byte
1021              +------------------------------------------+
1022           0  | magic number = 0x950412de                |
1023              |                                          |
1024           4  | file format revision = 0                 |
1025              |                                          |
1026           8  | number of strings                        |  == N
1027              |                                          |
1028          12  | offset of table with original strings    |  == O
1029              |                                          |
1030          16  | offset of table with translation strings |  == T
1031              |                                          |
1032          20  | size of hashing table                    |  == S
1033              |                                          |
1034          24  | offset of hashing table                  |  == H
1035              |                                          |
1036              .                                          .
1037              .    (possibly more entries later)         .
1038              .                                          .
1039              |                                          |
1040           O  | length &#38; offset 0th string  ----------------.
1041       O + 8  | length &#38; offset 1st string  ------------------.
1042               ...                                    ...   | |
1043 O + ((N-1)*8)| length &#38; offset (N-1)th string           |  | |
1044              |                                          |  | |
1045           T  | length &#38; offset 0th translation  ---------------.
1046       T + 8  | length &#38; offset 1st translation  -----------------.
1047               ...                                    ...   | | | |
1048 T + ((N-1)*8)| length &#38; offset (N-1)th translation      |  | | | |
1049              |                                          |  | | | |
1050           H  | start hash table                         |  | | | |
1051               ...                                    ...   | | | |
1052   H + S * 4  | end hash table                           |  | | | |
1053              |                                          |  | | | |
1054              | NUL terminated 0th string  &#60;----------------' | | |
1055              |                                          |    | | |
1056              | NUL terminated 1st string  &#60;------------------' | |
1057              |                                          |      | |
1058               ...                                    ...       | |
1059              |                                          |      | |
1060              | NUL terminated 0th translation  &#60;---------------' |
1061              |                                          |        |
1062              | NUL terminated 1st translation  &#60;-----------------'
1063              |                                          |
1064               ...                                    ...
1065              |                                          |
1066              +------------------------------------------+
1067 </PRE>
1068
1069 <P><HR><P>
1070 Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_9.html">previous</A>, <A HREF="gettext_11.html">next</A>, <A HREF="gettext_25.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
1071 </BODY>
1072 </HTML>