4fcd4268c376d6fc521adbac65e993128a175a40
[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 9 June 2016 -->
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 is <CODE>little</CODE>.
526
527 MO files of any endianness can be used on any platform.  When a MO file has
528 an endianness other than the platform's one, the 32-bit numbers from the MO
529 file are swapped at runtime.  The performance impact is negligible.
530
531 This option can be useful to produce MO files that are optimized for one
532 platform.
533
534 <DT><SAMP>&lsquo;--no-hash&rsquo;</SAMP>
535 <DD>
536 <A NAME="IDX1048"></A>
537 Don't include a hash table in the binary file.  Lookup will be more expensive
538 at run time (binary search instead of hash table lookup).
539
540 </DL>
541
542
543
544 <H3><A NAME="SEC169" HREF="gettext_toc.html#TOC169">10.1.12  Informative output</A></H3>
545
546 <DL COMPACT>
547
548 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
549 <DD>
550 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
551 <DD>
552 <A NAME="IDX1049"></A>
553 <A NAME="IDX1050"></A>
554 Display this help and exit.
555
556 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
557 <DD>
558 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
559 <DD>
560 <A NAME="IDX1051"></A>
561 <A NAME="IDX1052"></A>
562 Output version information and exit.
563
564 <DT><SAMP>&lsquo;--statistics&rsquo;</SAMP>
565 <DD>
566 <A NAME="IDX1053"></A>
567 Print statistics about translations.  When the option <CODE>--verbose</CODE> is used
568 in combination with <CODE>--statistics</CODE>, the input file name is printed in
569 front of the statistics line.
570
571 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
572 <DD>
573 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
574 <DD>
575 <A NAME="IDX1054"></A>
576 <A NAME="IDX1055"></A>
577 Increase verbosity level.
578
579 </DL>
580
581
582
583 <H2><A NAME="SEC170" HREF="gettext_toc.html#TOC170">10.2  Invoking the <CODE>msgunfmt</CODE> Program</A></H2>
584
585 <P>
586 <A NAME="IDX1056"></A>
587 <A NAME="IDX1057"></A>
588
589 <PRE>
590 msgunfmt [<VAR>option</VAR>] [<VAR>file</VAR>]...
591 </PRE>
592
593 <P>
594 <A NAME="IDX1058"></A>
595 The <CODE>msgunfmt</CODE> program converts a binary message catalog to a
596 Uniforum style .po file.
597
598 </P>
599
600
601 <H3><A NAME="SEC171" HREF="gettext_toc.html#TOC171">10.2.1  Operation mode</A></H3>
602
603 <DL COMPACT>
604
605 <DT><SAMP>&lsquo;-j&rsquo;</SAMP>
606 <DD>
607 <DT><SAMP>&lsquo;--java&rsquo;</SAMP>
608 <DD>
609 <A NAME="IDX1059"></A>
610 <A NAME="IDX1060"></A>
611 <A NAME="IDX1061"></A>
612 Java mode: input is a Java <CODE>ResourceBundle</CODE> class.
613
614 <DT><SAMP>&lsquo;--csharp&rsquo;</SAMP>
615 <DD>
616 <A NAME="IDX1062"></A>
617 <A NAME="IDX1063"></A>
618 C# mode: input is a .NET .dll file containing a subclass of
619 <CODE>GettextResourceSet</CODE>.
620
621 <DT><SAMP>&lsquo;--csharp-resources&rsquo;</SAMP>
622 <DD>
623 <A NAME="IDX1064"></A>
624 <A NAME="IDX1065"></A>
625 C# resources mode: input is a .NET <TT>&lsquo;.resources&rsquo;</TT> file.
626
627 <DT><SAMP>&lsquo;--tcl&rsquo;</SAMP>
628 <DD>
629 <A NAME="IDX1066"></A>
630 <A NAME="IDX1067"></A>
631 Tcl mode: input is a tcl/msgcat <TT>&lsquo;.msg&rsquo;</TT> file.
632
633 </DL>
634
635
636
637 <H3><A NAME="SEC172" HREF="gettext_toc.html#TOC172">10.2.2  Input file location</A></H3>
638
639 <DL COMPACT>
640
641 <DT><SAMP>&lsquo;<VAR>file</VAR> ...&rsquo;</SAMP>
642 <DD>
643 Input .mo files.
644
645 </DL>
646
647 <P>
648 If no input <VAR>file</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
649
650 </P>
651
652
653 <H3><A NAME="SEC173" HREF="gettext_toc.html#TOC173">10.2.3  Input file location in Java mode</A></H3>
654
655 <DL COMPACT>
656
657 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
658 <DD>
659 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
660 <DD>
661 <A NAME="IDX1068"></A>
662 <A NAME="IDX1069"></A>
663 Specify the resource name.
664
665 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
666 <DD>
667 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
668 <DD>
669 <A NAME="IDX1070"></A>
670 <A NAME="IDX1071"></A>
671 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
672 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
673
674 </DL>
675
676 <P>
677 The class name is determined by appending the locale name to the resource name,
678 separated with an underscore.  The class is located using the <CODE>CLASSPATH</CODE>.
679
680 </P>
681
682
683 <H3><A NAME="SEC174" HREF="gettext_toc.html#TOC174">10.2.4  Input file location in C# mode</A></H3>
684
685 <DL COMPACT>
686
687 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
688 <DD>
689 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
690 <DD>
691 <A NAME="IDX1072"></A>
692 <A NAME="IDX1073"></A>
693 Specify the resource name.
694
695 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
696 <DD>
697 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
698 <DD>
699 <A NAME="IDX1074"></A>
700 <A NAME="IDX1075"></A>
701 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
702 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
703
704 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
705 <DD>
706 <A NAME="IDX1076"></A>
707 Specify the base directory for locale dependent <TT>&lsquo;.dll&rsquo;</TT> files.
708
709 </DL>
710
711 <P>
712 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
713 located in a subdirectory of the specified directory whose name depends on the
714 locale.
715
716 </P>
717
718
719 <H3><A NAME="SEC175" HREF="gettext_toc.html#TOC175">10.2.5  Input file location in Tcl mode</A></H3>
720
721 <DL COMPACT>
722
723 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
724 <DD>
725 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
726 <DD>
727 <A NAME="IDX1077"></A>
728 <A NAME="IDX1078"></A>
729 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
730 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
731
732 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
733 <DD>
734 <A NAME="IDX1079"></A>
735 Specify the base directory of <TT>&lsquo;.msg&rsquo;</TT> message catalogs.
736
737 </DL>
738
739 <P>
740 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
741 located in the specified directory.
742
743 </P>
744
745
746 <H3><A NAME="SEC176" HREF="gettext_toc.html#TOC176">10.2.6  Output file location</A></H3>
747
748 <DL COMPACT>
749
750 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
751 <DD>
752 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
753 <DD>
754 <A NAME="IDX1080"></A>
755 <A NAME="IDX1081"></A>
756 Write output to specified file.
757
758 </DL>
759
760 <P>
761 The results are written to standard output if no output file is specified
762 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
763
764 </P>
765
766
767 <H3><A NAME="SEC177" HREF="gettext_toc.html#TOC177">10.2.7  Output details</A></H3>
768
769 <DL COMPACT>
770
771 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
772 <DD>
773 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
774 <DD>
775 <A NAME="IDX1082"></A>
776 Specify whether or when to use colors and other text attributes.
777 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
778
779 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
780 <DD>
781 <A NAME="IDX1083"></A>
782 Specify the CSS style rule file to use for <CODE>--color</CODE>.
783 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
784
785 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
786 <DD>
787 <A NAME="IDX1084"></A>
788 Always write an output file even if it contains no message.
789
790 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
791 <DD>
792 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
793 <DD>
794 <A NAME="IDX1085"></A>
795 <A NAME="IDX1086"></A>
796 Write the .po file using indented style.
797
798 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
799 <DD>
800 <A NAME="IDX1087"></A>
801 Write out a strict Uniforum conforming PO file.  Note that this
802 Uniforum format should be avoided because it doesn't support the
803 GNU extensions.
804
805 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
806 <DD>
807 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
808 <DD>
809 <A NAME="IDX1088"></A>
810 <A NAME="IDX1089"></A>
811 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
812 that this file format doesn't support plural forms and silently drops
813 obsolete messages.
814
815 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
816 <DD>
817 <A NAME="IDX1090"></A>
818 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
819 Note that this file format doesn't support plural forms.
820
821 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
822 <DD>
823 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
824 <DD>
825 <A NAME="IDX1091"></A>
826 <A NAME="IDX1092"></A>
827 Set the output page width.  Long strings in the output files will be
828 split across multiple lines in order to ensure that each line's width
829 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
830
831 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
832 <DD>
833 <A NAME="IDX1093"></A>
834 Do not break long message lines.  Message lines whose width exceeds the
835 output page width will not be split into several lines.  Only file reference
836 lines which are wider than the output page width will be split.
837
838 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
839 <DD>
840 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
841 <DD>
842 <A NAME="IDX1094"></A>
843 <A NAME="IDX1095"></A>
844 <A NAME="IDX1096"></A>
845 Generate sorted output.  Note that using this option makes it much harder
846 for the translator to understand each message's context.
847
848 </DL>
849
850
851
852 <H3><A NAME="SEC178" HREF="gettext_toc.html#TOC178">10.2.8  Informative output</A></H3>
853
854 <DL COMPACT>
855
856 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
857 <DD>
858 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
859 <DD>
860 <A NAME="IDX1097"></A>
861 <A NAME="IDX1098"></A>
862 Display this help and exit.
863
864 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
865 <DD>
866 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
867 <DD>
868 <A NAME="IDX1099"></A>
869 <A NAME="IDX1100"></A>
870 Output version information and exit.
871
872 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
873 <DD>
874 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
875 <DD>
876 <A NAME="IDX1101"></A>
877 <A NAME="IDX1102"></A>
878 Increase verbosity level.
879
880 </DL>
881
882
883
884 <H2><A NAME="SEC179" HREF="gettext_toc.html#TOC179">10.3  The Format of GNU MO Files</A></H2>
885 <P>
886 <A NAME="IDX1103"></A>
887 <A NAME="IDX1104"></A>
888
889 </P>
890 <P>
891 The format of the generated MO files is best described by a picture,
892 which appears below.
893
894 </P>
895 <P>
896 <A NAME="IDX1105"></A>
897 The first two words serve the identification of the file.  The magic
898 number will always signal GNU MO files.  The number is stored in the
899 byte order used when the MO file was generated, so the magic number
900 really is two numbers: <CODE>0x950412de</CODE> and <CODE>0xde120495</CODE>.
901
902 </P>
903 <P>
904 The second word describes the current revision of the file format,
905 composed of a major and a minor revision number.  The revision numbers
906 ensure that the readers of MO files can distinguish new formats from
907 old ones and handle their contents, as far as possible.  For now the
908 major revision is 0 or 1, and the minor revision is also 0 or 1.  More
909 revisions might be added in the future.  A program seeing an unexpected
910 major revision number should stop reading the MO file entirely; whereas
911 an unexpected minor revision number means that the file can be read but
912 will not reveal its full contents, when parsed by a program that
913 supports only smaller minor revision numbers.
914
915 </P>
916 <P>
917 The version is kept
918 separate from the magic number, instead of using different magic
919 numbers for different formats, mainly because <TT>&lsquo;/etc/magic&rsquo;</TT> is
920 not updated often.
921
922 </P>
923 <P>
924 Follow a number of pointers to later tables in the file, allowing
925 for the extension of the prefix part of MO files without having to
926 recompile programs reading them.  This might become useful for later
927 inserting a few flag bits, indication about the charset used, new
928 tables, or other things.
929
930 </P>
931 <P>
932 Then, at offset <VAR>O</VAR> and offset <VAR>T</VAR> in the picture, two tables
933 of string descriptors can be found.  In both tables, each string
934 descriptor uses two 32 bits integers, one for the string length,
935 another for the offset of the string in the MO file, counting in bytes
936 from the start of the file.  The first table contains descriptors
937 for the original strings, and is sorted so the original strings
938 are in increasing lexicographical order.  The second table contains
939 descriptors for the translated strings, and is parallel to the first
940 table: to find the corresponding translation one has to access the
941 array slot in the second array with the same index.
942
943 </P>
944 <P>
945 Having the original strings sorted enables the use of simple binary
946 search, for when the MO file does not contain an hashing table, or
947 for when it is not practical to use the hashing table provided in
948 the MO file.  This also has another advantage, as the empty string
949 in a PO file GNU <CODE>gettext</CODE> is usually <EM>translated</EM> into
950 some system information attached to that particular MO file, and the
951 empty string necessarily becomes the first in both the original and
952 translated tables, making the system information very easy to find.
953
954 </P>
955 <P>
956 <A NAME="IDX1106"></A>
957 The size <VAR>S</VAR> of the hash table can be zero.  In this case, the
958 hash table itself is not contained in the MO file.  Some people might
959 prefer this because a precomputed hashing table takes disk space, and
960 does not win <EM>that</EM> much speed.  The hash table contains indices
961 to the sorted array of strings in the MO file.  Conflict resolution is
962 done by double hashing.  The precise hashing algorithm used is fairly
963 dependent on GNU <CODE>gettext</CODE> code, and is not documented here.
964
965 </P>
966 <P>
967 As for the strings themselves, they follow the hash file, and each
968 is terminated with a <KBD>NUL</KBD>, and this <KBD>NUL</KBD> is not counted in
969 the length which appears in the string descriptor.  The <CODE>msgfmt</CODE>
970 program has an option selecting the alignment for MO file strings.
971 With this option, each string is separately aligned so it starts at
972 an offset which is a multiple of the alignment value.  On some RISC
973 machines, a correct alignment will speed things up.
974
975 </P>
976 <P>
977 <A NAME="IDX1107"></A>
978 Contexts are stored by storing the concatenation of the context, a
979 <KBD>EOT</KBD> byte, and the original string, instead of the original string.
980
981 </P>
982 <P>
983 <A NAME="IDX1108"></A>
984 Plural forms are stored by letting the plural of the original string
985 follow the singular of the original string, separated through a
986 <KBD>NUL</KBD> byte.  The length which appears in the string descriptor
987 includes both.  However, only the singular of the original string
988 takes part in the hash table lookup.  The plural variants of the
989 translation are all stored consecutively, separated through a
990 <KBD>NUL</KBD> byte.  Here also, the length in the string descriptor
991 includes all of them.
992
993 </P>
994 <P>
995 Nothing prevents a MO file from having embedded <KBD>NUL</KBD>s in strings.
996 However, the program interface currently used already presumes
997 that strings are <KBD>NUL</KBD> terminated, so embedded <KBD>NUL</KBD>s are
998 somewhat useless.  But the MO file format is general enough so other
999 interfaces would be later possible, if for example, we ever want to
1000 implement wide characters right in MO files, where <KBD>NUL</KBD> bytes may
1001 accidentally appear.  (No, we don't want to have wide characters in MO
1002 files.  They would make the file unnecessarily large, and the
1003 <SAMP>&lsquo;wchar_t&rsquo;</SAMP> type being platform dependent, MO files would be
1004 platform dependent as well.)
1005
1006 </P>
1007 <P>
1008 This particular issue has been strongly debated in the GNU
1009 <CODE>gettext</CODE> development forum, and it is expectable that MO file
1010 format will evolve or change over time.  It is even possible that many
1011 formats may later be supported concurrently.  But surely, we have to
1012 start somewhere, and the MO file format described here is a good start.
1013 Nothing is cast in concrete, and the format may later evolve fairly
1014 easily, so we should feel comfortable with the current approach.
1015
1016 </P>
1017
1018 <PRE>
1019         byte
1020              +------------------------------------------+
1021           0  | magic number = 0x950412de                |
1022              |                                          |
1023           4  | file format revision = 0                 |
1024              |                                          |
1025           8  | number of strings                        |  == N
1026              |                                          |
1027          12  | offset of table with original strings    |  == O
1028              |                                          |
1029          16  | offset of table with translation strings |  == T
1030              |                                          |
1031          20  | size of hashing table                    |  == S
1032              |                                          |
1033          24  | offset of hashing table                  |  == H
1034              |                                          |
1035              .                                          .
1036              .    (possibly more entries later)         .
1037              .                                          .
1038              |                                          |
1039           O  | length &#38; offset 0th string  ----------------.
1040       O + 8  | length &#38; offset 1st string  ------------------.
1041               ...                                    ...   | |
1042 O + ((N-1)*8)| length &#38; offset (N-1)th string           |  | |
1043              |                                          |  | |
1044           T  | length &#38; offset 0th translation  ---------------.
1045       T + 8  | length &#38; offset 1st translation  -----------------.
1046               ...                                    ...   | | | |
1047 T + ((N-1)*8)| length &#38; offset (N-1)th translation      |  | | | |
1048              |                                          |  | | | |
1049           H  | start hash table                         |  | | | |
1050               ...                                    ...   | | | |
1051   H + S * 4  | end hash table                           |  | | | |
1052              |                                          |  | | | |
1053              | NUL terminated 0th string  &#60;----------------' | | |
1054              |                                          |    | | |
1055              | NUL terminated 1st string  &#60;------------------' | |
1056              |                                          |      | |
1057               ...                                    ...       | |
1058              |                                          |      | |
1059              | NUL terminated 0th translation  &#60;---------------' |
1060              |                                          |        |
1061              | NUL terminated 1st translation  &#60;-----------------'
1062              |                                          |
1063               ...                                    ...
1064              |                                          |
1065              +------------------------------------------+
1066 </PRE>
1067
1068 <P><HR><P>
1069 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>.
1070 </BODY>
1071 </HTML>