Imported Upstream version 0.18.1.1
[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 6 June 2010 -->
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="IDX947"></A>
22 <A NAME="IDX948"></A>
23
24 <PRE>
25 msgfmt [<VAR>option</VAR>] <VAR>filename</VAR>.po ...
26 </PRE>
27
28 <P>
29 <A NAME="IDX949"></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="IDX950"></A>
47 <A NAME="IDX951"></A>
48 Add <VAR>directory</VAR> to the list of directories.  Source files are
49 searched relative to this list of directories.  The resulting <TT>&lsquo;.po&rsquo;</TT>
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="IDX952"></A>
69 <A NAME="IDX953"></A>
70 <A NAME="IDX954"></A>
71 Java mode: generate a Java <CODE>ResourceBundle</CODE> class.
72
73 <DT><SAMP>&lsquo;--java2&rsquo;</SAMP>
74 <DD>
75 <A NAME="IDX955"></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="IDX956"></A>
81 <A NAME="IDX957"></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="IDX958"></A>
88 <A NAME="IDX959"></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="IDX960"></A>
94 <A NAME="IDX961"></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="IDX962"></A>
100 <A NAME="IDX963"></A>
101 Qt mode: generate a Qt <TT>&lsquo;.qm&rsquo;</TT> file.
102
103 </DL>
104
105
106
107 <H3><A NAME="SEC160" HREF="gettext_toc.html#TOC160">10.1.3  Output file location</A></H3>
108
109 <DL COMPACT>
110
111 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
112 <DD>
113 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
114 <DD>
115 <A NAME="IDX964"></A>
116 <A NAME="IDX965"></A>
117 Write output to specified file.
118
119 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
120 <DD>
121 <A NAME="IDX966"></A>
122 Direct the program to work strictly following the Uniforum/Sun
123 implementation.  Currently this only affects the naming of the output
124 file.  If this option is not given the name of the output file is the
125 same as the domain name.  If the strict Uniforum mode is enabled the
126 suffix <TT>&lsquo;.mo&rsquo;</TT> is added to the file name if it is not already
127 present.
128
129 We find this behaviour of Sun's implementation rather silly and so by
130 default this mode is <EM>not</EM> selected.
131
132 </DL>
133
134 <P>
135 If the output <VAR>file</VAR> is <SAMP>&lsquo;-&rsquo;</SAMP>, output is written to standard output.
136
137 </P>
138
139
140 <H3><A NAME="SEC161" HREF="gettext_toc.html#TOC161">10.1.4  Output file location in Java mode</A></H3>
141
142 <DL COMPACT>
143
144 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
145 <DD>
146 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
147 <DD>
148 <A NAME="IDX967"></A>
149 <A NAME="IDX968"></A>
150 Specify the resource name.
151
152 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
153 <DD>
154 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
155 <DD>
156 <A NAME="IDX969"></A>
157 <A NAME="IDX970"></A>
158 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
159 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
160
161 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
162 <DD>
163 <A NAME="IDX971"></A>
164 Specify the base directory of classes directory hierarchy.
165
166 </DL>
167
168 <P>
169 The class name is determined by appending the locale name to the resource name,
170 separated with an underscore.  The <SAMP>&lsquo;-d&rsquo;</SAMP> option is mandatory.  The class
171 is written under the specified directory.
172
173 </P>
174
175
176 <H3><A NAME="SEC162" HREF="gettext_toc.html#TOC162">10.1.5  Output file location in C# mode</A></H3>
177
178 <DL COMPACT>
179
180 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
181 <DD>
182 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
183 <DD>
184 <A NAME="IDX972"></A>
185 <A NAME="IDX973"></A>
186 Specify the resource name.
187
188 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
189 <DD>
190 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
191 <DD>
192 <A NAME="IDX974"></A>
193 <A NAME="IDX975"></A>
194 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
195 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
196
197 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
198 <DD>
199 <A NAME="IDX976"></A>
200 Specify the base directory for locale dependent <TT>&lsquo;.dll&rsquo;</TT> files.
201
202 </DL>
203
204 <P>
205 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.dll&rsquo;</TT> file is
206 written in a subdirectory of the specified directory whose name depends on the
207 locale.
208
209 </P>
210
211
212 <H3><A NAME="SEC163" HREF="gettext_toc.html#TOC163">10.1.6  Output file location in Tcl mode</A></H3>
213
214 <DL COMPACT>
215
216 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
217 <DD>
218 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
219 <DD>
220 <A NAME="IDX977"></A>
221 <A NAME="IDX978"></A>
222 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
223 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
224
225 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
226 <DD>
227 <A NAME="IDX979"></A>
228 Specify the base directory of <TT>&lsquo;.msg&rsquo;</TT> message catalogs.
229
230 </DL>
231
232 <P>
233 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
234 written in the specified directory.
235
236 </P>
237
238
239 <H3><A NAME="SEC164" HREF="gettext_toc.html#TOC164">10.1.7  Input file syntax</A></H3>
240
241 <DL COMPACT>
242
243 <DT><SAMP>&lsquo;-P&rsquo;</SAMP>
244 <DD>
245 <DT><SAMP>&lsquo;--properties-input&rsquo;</SAMP>
246 <DD>
247 <A NAME="IDX980"></A>
248 <A NAME="IDX981"></A>
249 Assume the input files are Java ResourceBundles in Java <CODE>.properties</CODE>
250 syntax, not in PO file syntax.
251
252 <DT><SAMP>&lsquo;--stringtable-input&rsquo;</SAMP>
253 <DD>
254 <A NAME="IDX982"></A>
255 Assume the input files are NeXTstep/GNUstep localized resource files in
256 <CODE>.strings</CODE> syntax, not in PO file syntax.
257
258 </DL>
259
260
261
262 <H3><A NAME="SEC165" HREF="gettext_toc.html#TOC165">10.1.8  Input file interpretation</A></H3>
263
264 <DL COMPACT>
265
266 <DT><SAMP>&lsquo;-c&rsquo;</SAMP>
267 <DD>
268 <DT><SAMP>&lsquo;--check&rsquo;</SAMP>
269 <DD>
270 <A NAME="IDX983"></A>
271 <A NAME="IDX984"></A>
272 Perform all the checks implied by <CODE>--check-format</CODE>, <CODE>--check-header</CODE>,
273 <CODE>--check-domain</CODE>.
274
275 <DT><SAMP>&lsquo;--check-format&rsquo;</SAMP>
276 <DD>
277 <A NAME="IDX985"></A>
278 <A NAME="IDX986"></A>
279 Check language dependent format strings.
280
281 If the string represents a format string used in a
282 <CODE>printf</CODE>-like function both strings should have the same number of
283 <SAMP>&lsquo;%&rsquo;</SAMP> format specifiers, with matching types.  If the flag
284 <CODE>c-format</CODE> or <CODE>possible-c-format</CODE> appears in the special
285 comment <KBD>#,</KBD> for this entry a check is performed.  For example, the
286 check will diagnose using <SAMP>&lsquo;%.*s&rsquo;</SAMP> against <SAMP>&lsquo;%s&rsquo;</SAMP>, or <SAMP>&lsquo;%d&rsquo;</SAMP>
287 against <SAMP>&lsquo;%s&rsquo;</SAMP>, or <SAMP>&lsquo;%d&rsquo;</SAMP> against <SAMP>&lsquo;%x&rsquo;</SAMP>.  It can even handle
288 positional parameters.
289
290 Normally the <CODE>xgettext</CODE> program automatically decides whether a
291 string is a format string or not.  This algorithm is not perfect,
292 though.  It might regard a string as a format string though it is not
293 used in a <CODE>printf</CODE>-like function and so <CODE>msgfmt</CODE> might report
294 errors where there are none.
295
296 To solve this problem the programmer can dictate the decision to the
297 <CODE>xgettext</CODE> program (see section <A HREF="gettext_15.html#SEC249">15.3.1  C Format Strings</A>).  The translator should not
298 consider removing the flag from the <KBD>#,</KBD> line.  This "fix" would be
299 reversed again as soon as <CODE>msgmerge</CODE> is called the next time.
300
301 <DT><SAMP>&lsquo;--check-header&rsquo;</SAMP>
302 <DD>
303 <A NAME="IDX987"></A>
304 Verify presence and contents of the header entry.  See section <A HREF="gettext_6.html#SEC44">6.2  Filling in the Header Entry</A>,
305 for a description of the various fields in the header entry.
306
307 <DT><SAMP>&lsquo;--check-domain&rsquo;</SAMP>
308 <DD>
309 <A NAME="IDX988"></A>
310 Check for conflicts between domain directives and the <CODE>--output-file</CODE>
311 option
312
313 <DT><SAMP>&lsquo;-C&rsquo;</SAMP>
314 <DD>
315 <DT><SAMP>&lsquo;--check-compatibility&rsquo;</SAMP>
316 <DD>
317 <A NAME="IDX989"></A>
318 <A NAME="IDX990"></A>
319 <A NAME="IDX991"></A>
320 Check that GNU msgfmt behaves like X/Open msgfmt.  This will give an error
321 when attempting to use the GNU extensions.
322
323 <DT><SAMP>&lsquo;--check-accelerators[=<VAR>char</VAR>]&rsquo;</SAMP>
324 <DD>
325 <A NAME="IDX992"></A>
326 <A NAME="IDX993"></A>
327 <A NAME="IDX994"></A>
328 <A NAME="IDX995"></A>
329 Check presence of keyboard accelerators for menu items.  This is based on
330 the convention used in some GUIs that a keyboard accelerator in a menu
331 item string is designated by an immediately preceding <SAMP>&lsquo;&#38;&rsquo;</SAMP> character.
332 Sometimes a keyboard accelerator is also called "keyboard mnemonic".
333 This check verifies that if the untranslated string has exactly one
334 <SAMP>&lsquo;&#38;&rsquo;</SAMP> character, the translated string has exactly one <SAMP>&lsquo;&#38;&rsquo;</SAMP> as well.
335 If this option is given with a <VAR>char</VAR> argument, this <VAR>char</VAR> should
336 be a non-alphanumeric character and is used as keyboard accelerator mark
337 instead of <SAMP>&lsquo;&#38;&rsquo;</SAMP>.
338
339 <DT><SAMP>&lsquo;-f&rsquo;</SAMP>
340 <DD>
341 <DT><SAMP>&lsquo;--use-fuzzy&rsquo;</SAMP>
342 <DD>
343 <A NAME="IDX996"></A>
344 <A NAME="IDX997"></A>
345 <A NAME="IDX998"></A>
346 Use fuzzy entries in output.  Note that using this option is usually wrong,
347 because fuzzy messages are exactly those which have not been validated by
348 a human translator.
349
350 </DL>
351
352
353
354 <H3><A NAME="SEC166" HREF="gettext_toc.html#TOC166">10.1.9  Output details</A></H3>
355
356 <DL COMPACT>
357
358 <DT><SAMP>&lsquo;-a <VAR>number</VAR>&rsquo;</SAMP>
359 <DD>
360 <DT><SAMP>&lsquo;--alignment=<VAR>number</VAR>&rsquo;</SAMP>
361 <DD>
362 <A NAME="IDX999"></A>
363 <A NAME="IDX1000"></A>
364 Align strings to <VAR>number</VAR> bytes (default: 1).
365
366 <DT><SAMP>&lsquo;--no-hash&rsquo;</SAMP>
367 <DD>
368 <A NAME="IDX1001"></A>
369 Don't include a hash table in the binary file.  Lookup will be more expensive
370 at run time (binary search instead of hash table lookup).
371
372 </DL>
373
374
375
376 <H3><A NAME="SEC167" HREF="gettext_toc.html#TOC167">10.1.10  Informative output</A></H3>
377
378 <DL COMPACT>
379
380 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
381 <DD>
382 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
383 <DD>
384 <A NAME="IDX1002"></A>
385 <A NAME="IDX1003"></A>
386 Display this help and exit.
387
388 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
389 <DD>
390 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
391 <DD>
392 <A NAME="IDX1004"></A>
393 <A NAME="IDX1005"></A>
394 Output version information and exit.
395
396 <DT><SAMP>&lsquo;--statistics&rsquo;</SAMP>
397 <DD>
398 <A NAME="IDX1006"></A>
399 Print statistics about translations.  When the option <CODE>--verbose</CODE> is used
400 in combination with <CODE>--statistics</CODE>, the input file name is printed in
401 front of the statistics line.
402
403 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
404 <DD>
405 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
406 <DD>
407 <A NAME="IDX1007"></A>
408 <A NAME="IDX1008"></A>
409 Increase verbosity level.
410
411 </DL>
412
413
414
415 <H2><A NAME="SEC168" HREF="gettext_toc.html#TOC168">10.2  Invoking the <CODE>msgunfmt</CODE> Program</A></H2>
416
417 <P>
418 <A NAME="IDX1009"></A>
419 <A NAME="IDX1010"></A>
420
421 <PRE>
422 msgunfmt [<VAR>option</VAR>] [<VAR>file</VAR>]...
423 </PRE>
424
425 <P>
426 <A NAME="IDX1011"></A>
427 The <CODE>msgunfmt</CODE> program converts a binary message catalog to a
428 Uniforum style .po file.
429
430 </P>
431
432
433 <H3><A NAME="SEC169" HREF="gettext_toc.html#TOC169">10.2.1  Operation mode</A></H3>
434
435 <DL COMPACT>
436
437 <DT><SAMP>&lsquo;-j&rsquo;</SAMP>
438 <DD>
439 <DT><SAMP>&lsquo;--java&rsquo;</SAMP>
440 <DD>
441 <A NAME="IDX1012"></A>
442 <A NAME="IDX1013"></A>
443 <A NAME="IDX1014"></A>
444 Java mode: input is a Java <CODE>ResourceBundle</CODE> class.
445
446 <DT><SAMP>&lsquo;--csharp&rsquo;</SAMP>
447 <DD>
448 <A NAME="IDX1015"></A>
449 <A NAME="IDX1016"></A>
450 C# mode: input is a .NET .dll file containing a subclass of
451 <CODE>GettextResourceSet</CODE>.
452
453 <DT><SAMP>&lsquo;--csharp-resources&rsquo;</SAMP>
454 <DD>
455 <A NAME="IDX1017"></A>
456 <A NAME="IDX1018"></A>
457 C# resources mode: input is a .NET <TT>&lsquo;.resources&rsquo;</TT> file.
458
459 <DT><SAMP>&lsquo;--tcl&rsquo;</SAMP>
460 <DD>
461 <A NAME="IDX1019"></A>
462 <A NAME="IDX1020"></A>
463 Tcl mode: input is a tcl/msgcat <TT>&lsquo;.msg&rsquo;</TT> file.
464
465 </DL>
466
467
468
469 <H3><A NAME="SEC170" HREF="gettext_toc.html#TOC170">10.2.2  Input file location</A></H3>
470
471 <DL COMPACT>
472
473 <DT><SAMP>&lsquo;<VAR>file</VAR> ...&rsquo;</SAMP>
474 <DD>
475 Input .mo files.
476
477 </DL>
478
479 <P>
480 If no input <VAR>file</VAR> is given or if it is <SAMP>&lsquo;-&rsquo;</SAMP>, standard input is read.
481
482 </P>
483
484
485 <H3><A NAME="SEC171" HREF="gettext_toc.html#TOC171">10.2.3  Input file location in Java mode</A></H3>
486
487 <DL COMPACT>
488
489 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
490 <DD>
491 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
492 <DD>
493 <A NAME="IDX1021"></A>
494 <A NAME="IDX1022"></A>
495 Specify the resource name.
496
497 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
498 <DD>
499 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
500 <DD>
501 <A NAME="IDX1023"></A>
502 <A NAME="IDX1024"></A>
503 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
504 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
505
506 </DL>
507
508 <P>
509 The class name is determined by appending the locale name to the resource name,
510 separated with an underscore.  The class is located using the <CODE>CLASSPATH</CODE>.
511
512 </P>
513
514
515 <H3><A NAME="SEC172" HREF="gettext_toc.html#TOC172">10.2.4  Input file location in C# mode</A></H3>
516
517 <DL COMPACT>
518
519 <DT><SAMP>&lsquo;-r <VAR>resource</VAR>&rsquo;</SAMP>
520 <DD>
521 <DT><SAMP>&lsquo;--resource=<VAR>resource</VAR>&rsquo;</SAMP>
522 <DD>
523 <A NAME="IDX1025"></A>
524 <A NAME="IDX1026"></A>
525 Specify the resource name.
526
527 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
528 <DD>
529 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
530 <DD>
531 <A NAME="IDX1027"></A>
532 <A NAME="IDX1028"></A>
533 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
534 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
535
536 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
537 <DD>
538 <A NAME="IDX1029"></A>
539 Specify the base directory for locale dependent <TT>&lsquo;.dll&rsquo;</TT> files.
540
541 </DL>
542
543 <P>
544 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
545 located in a subdirectory of the specified directory whose name depends on the
546 locale.
547
548 </P>
549
550
551 <H3><A NAME="SEC173" HREF="gettext_toc.html#TOC173">10.2.5  Input file location in Tcl mode</A></H3>
552
553 <DL COMPACT>
554
555 <DT><SAMP>&lsquo;-l <VAR>locale</VAR>&rsquo;</SAMP>
556 <DD>
557 <DT><SAMP>&lsquo;--locale=<VAR>locale</VAR>&rsquo;</SAMP>
558 <DD>
559 <A NAME="IDX1030"></A>
560 <A NAME="IDX1031"></A>
561 Specify the locale name, either a language specification of the form <VAR>ll</VAR>
562 or a combined language and country specification of the form <VAR>ll_CC</VAR>.
563
564 <DT><SAMP>&lsquo;-d <VAR>directory</VAR>&rsquo;</SAMP>
565 <DD>
566 <A NAME="IDX1032"></A>
567 Specify the base directory of <TT>&lsquo;.msg&rsquo;</TT> message catalogs.
568
569 </DL>
570
571 <P>
572 The <SAMP>&lsquo;-l&rsquo;</SAMP> and <SAMP>&lsquo;-d&rsquo;</SAMP> options are mandatory.  The <TT>&lsquo;.msg&rsquo;</TT> file is
573 located in the specified directory.
574
575 </P>
576
577
578 <H3><A NAME="SEC174" HREF="gettext_toc.html#TOC174">10.2.6  Output file location</A></H3>
579
580 <DL COMPACT>
581
582 <DT><SAMP>&lsquo;-o <VAR>file</VAR>&rsquo;</SAMP>
583 <DD>
584 <DT><SAMP>&lsquo;--output-file=<VAR>file</VAR>&rsquo;</SAMP>
585 <DD>
586 <A NAME="IDX1033"></A>
587 <A NAME="IDX1034"></A>
588 Write output to specified file.
589
590 </DL>
591
592 <P>
593 The results are written to standard output if no output file is specified
594 or if it is <SAMP>&lsquo;-&rsquo;</SAMP>.
595
596 </P>
597
598
599 <H3><A NAME="SEC175" HREF="gettext_toc.html#TOC175">10.2.7  Output details</A></H3>
600
601 <DL COMPACT>
602
603 <DT><SAMP>&lsquo;--color&rsquo;</SAMP>
604 <DD>
605 <DT><SAMP>&lsquo;--color=<VAR>when</VAR>&rsquo;</SAMP>
606 <DD>
607 <A NAME="IDX1035"></A>
608 Specify whether or when to use colors and other text attributes.
609 See section <A HREF="gettext_9.html#SEC150">9.11.1  The <CODE>--color</CODE> option</A> for details.
610
611 <DT><SAMP>&lsquo;--style=<VAR>style_file</VAR>&rsquo;</SAMP>
612 <DD>
613 <A NAME="IDX1036"></A>
614 Specify the CSS style rule file to use for <CODE>--color</CODE>.
615 See section <A HREF="gettext_9.html#SEC152">9.11.3  The <CODE>--style</CODE> option</A> for details.
616
617 <DT><SAMP>&lsquo;--force-po&rsquo;</SAMP>
618 <DD>
619 <A NAME="IDX1037"></A>
620 Always write an output file even if it contains no message.
621
622 <DT><SAMP>&lsquo;-i&rsquo;</SAMP>
623 <DD>
624 <DT><SAMP>&lsquo;--indent&rsquo;</SAMP>
625 <DD>
626 <A NAME="IDX1038"></A>
627 <A NAME="IDX1039"></A>
628 Write the .po file using indented style.
629
630 <DT><SAMP>&lsquo;--strict&rsquo;</SAMP>
631 <DD>
632 <A NAME="IDX1040"></A>
633 Write out a strict Uniforum conforming PO file.  Note that this
634 Uniforum format should be avoided because it doesn't support the
635 GNU extensions.
636
637 <DT><SAMP>&lsquo;-p&rsquo;</SAMP>
638 <DD>
639 <DT><SAMP>&lsquo;--properties-output&rsquo;</SAMP>
640 <DD>
641 <A NAME="IDX1041"></A>
642 <A NAME="IDX1042"></A>
643 Write out a Java ResourceBundle in Java <CODE>.properties</CODE> syntax.  Note
644 that this file format doesn't support plural forms and silently drops
645 obsolete messages.
646
647 <DT><SAMP>&lsquo;--stringtable-output&rsquo;</SAMP>
648 <DD>
649 <A NAME="IDX1043"></A>
650 Write out a NeXTstep/GNUstep localized resource file in <CODE>.strings</CODE> syntax.
651 Note that this file format doesn't support plural forms.
652
653 <DT><SAMP>&lsquo;-w <VAR>number</VAR>&rsquo;</SAMP>
654 <DD>
655 <DT><SAMP>&lsquo;--width=<VAR>number</VAR>&rsquo;</SAMP>
656 <DD>
657 <A NAME="IDX1044"></A>
658 <A NAME="IDX1045"></A>
659 Set the output page width.  Long strings in the output files will be
660 split across multiple lines in order to ensure that each line's width
661 (= number of screen columns) is less or equal to the given <VAR>number</VAR>.
662
663 <DT><SAMP>&lsquo;--no-wrap&rsquo;</SAMP>
664 <DD>
665 <A NAME="IDX1046"></A>
666 Do not break long message lines.  Message lines whose width exceeds the
667 output page width will not be split into several lines.  Only file reference
668 lines which are wider than the output page width will be split.
669
670 <DT><SAMP>&lsquo;-s&rsquo;</SAMP>
671 <DD>
672 <DT><SAMP>&lsquo;--sort-output&rsquo;</SAMP>
673 <DD>
674 <A NAME="IDX1047"></A>
675 <A NAME="IDX1048"></A>
676 <A NAME="IDX1049"></A>
677 Generate sorted output.  Note that using this option makes it much harder
678 for the translator to understand each message's context.
679
680 </DL>
681
682
683
684 <H3><A NAME="SEC176" HREF="gettext_toc.html#TOC176">10.2.8  Informative output</A></H3>
685
686 <DL COMPACT>
687
688 <DT><SAMP>&lsquo;-h&rsquo;</SAMP>
689 <DD>
690 <DT><SAMP>&lsquo;--help&rsquo;</SAMP>
691 <DD>
692 <A NAME="IDX1050"></A>
693 <A NAME="IDX1051"></A>
694 Display this help and exit.
695
696 <DT><SAMP>&lsquo;-V&rsquo;</SAMP>
697 <DD>
698 <DT><SAMP>&lsquo;--version&rsquo;</SAMP>
699 <DD>
700 <A NAME="IDX1052"></A>
701 <A NAME="IDX1053"></A>
702 Output version information and exit.
703
704 <DT><SAMP>&lsquo;-v&rsquo;</SAMP>
705 <DD>
706 <DT><SAMP>&lsquo;--verbose&rsquo;</SAMP>
707 <DD>
708 <A NAME="IDX1054"></A>
709 <A NAME="IDX1055"></A>
710 Increase verbosity level.
711
712 </DL>
713
714
715
716 <H2><A NAME="SEC177" HREF="gettext_toc.html#TOC177">10.3  The Format of GNU MO Files</A></H2>
717 <P>
718 <A NAME="IDX1056"></A>
719 <A NAME="IDX1057"></A>
720
721 </P>
722 <P>
723 The format of the generated MO files is best described by a picture,
724 which appears below.
725
726 </P>
727 <P>
728 <A NAME="IDX1058"></A>
729 The first two words serve the identification of the file.  The magic
730 number will always signal GNU MO files.  The number is stored in the
731 byte order of the generating machine, so the magic number really is
732 two numbers: <CODE>0x950412de</CODE> and <CODE>0xde120495</CODE>.
733
734 </P>
735 <P>
736 The second word describes the current revision of the file format,
737 composed of a major and a minor revision number.  The revision numbers
738 ensure that the readers of MO files can distinguish new formats from
739 old ones and handle their contents, as far as possible.  For now the
740 major revision is 0 or 1, and the minor revision is also 0 or 1.  More
741 revisions might be added in the future.  A program seeing an unexpected
742 major revision number should stop reading the MO file entirely; whereas
743 an unexpected minor revision number means that the file can be read but
744 will not reveal its full contents, when parsed by a program that
745 supports only smaller minor revision numbers.
746
747 </P>
748 <P>
749 The version is kept
750 separate from the magic number, instead of using different magic
751 numbers for different formats, mainly because <TT>&lsquo;/etc/magic&rsquo;</TT> is
752 not updated often.
753
754 </P>
755 <P>
756 Follow a number of pointers to later tables in the file, allowing
757 for the extension of the prefix part of MO files without having to
758 recompile programs reading them.  This might become useful for later
759 inserting a few flag bits, indication about the charset used, new
760 tables, or other things.
761
762 </P>
763 <P>
764 Then, at offset <VAR>O</VAR> and offset <VAR>T</VAR> in the picture, two tables
765 of string descriptors can be found.  In both tables, each string
766 descriptor uses two 32 bits integers, one for the string length,
767 another for the offset of the string in the MO file, counting in bytes
768 from the start of the file.  The first table contains descriptors
769 for the original strings, and is sorted so the original strings
770 are in increasing lexicographical order.  The second table contains
771 descriptors for the translated strings, and is parallel to the first
772 table: to find the corresponding translation one has to access the
773 array slot in the second array with the same index.
774
775 </P>
776 <P>
777 Having the original strings sorted enables the use of simple binary
778 search, for when the MO file does not contain an hashing table, or
779 for when it is not practical to use the hashing table provided in
780 the MO file.  This also has another advantage, as the empty string
781 in a PO file GNU <CODE>gettext</CODE> is usually <EM>translated</EM> into
782 some system information attached to that particular MO file, and the
783 empty string necessarily becomes the first in both the original and
784 translated tables, making the system information very easy to find.
785
786 </P>
787 <P>
788 <A NAME="IDX1059"></A>
789 The size <VAR>S</VAR> of the hash table can be zero.  In this case, the
790 hash table itself is not contained in the MO file.  Some people might
791 prefer this because a precomputed hashing table takes disk space, and
792 does not win <EM>that</EM> much speed.  The hash table contains indices
793 to the sorted array of strings in the MO file.  Conflict resolution is
794 done by double hashing.  The precise hashing algorithm used is fairly
795 dependent on GNU <CODE>gettext</CODE> code, and is not documented here.
796
797 </P>
798 <P>
799 As for the strings themselves, they follow the hash file, and each
800 is terminated with a <KBD>NUL</KBD>, and this <KBD>NUL</KBD> is not counted in
801 the length which appears in the string descriptor.  The <CODE>msgfmt</CODE>
802 program has an option selecting the alignment for MO file strings.
803 With this option, each string is separately aligned so it starts at
804 an offset which is a multiple of the alignment value.  On some RISC
805 machines, a correct alignment will speed things up.
806
807 </P>
808 <P>
809 <A NAME="IDX1060"></A>
810 Contexts are stored by storing the concatenation of the context, a
811 <KBD>EOT</KBD> byte, and the original string, instead of the original string.
812
813 </P>
814 <P>
815 <A NAME="IDX1061"></A>
816 Plural forms are stored by letting the plural of the original string
817 follow the singular of the original string, separated through a
818 <KBD>NUL</KBD> byte.  The length which appears in the string descriptor
819 includes both.  However, only the singular of the original string
820 takes part in the hash table lookup.  The plural variants of the
821 translation are all stored consecutively, separated through a
822 <KBD>NUL</KBD> byte.  Here also, the length in the string descriptor
823 includes all of them.
824
825 </P>
826 <P>
827 Nothing prevents a MO file from having embedded <KBD>NUL</KBD>s in strings.
828 However, the program interface currently used already presumes
829 that strings are <KBD>NUL</KBD> terminated, so embedded <KBD>NUL</KBD>s are
830 somewhat useless.  But the MO file format is general enough so other
831 interfaces would be later possible, if for example, we ever want to
832 implement wide characters right in MO files, where <KBD>NUL</KBD> bytes may
833 accidentally appear.  (No, we don't want to have wide characters in MO
834 files.  They would make the file unnecessarily large, and the
835 <SAMP>&lsquo;wchar_t&rsquo;</SAMP> type being platform dependent, MO files would be
836 platform dependent as well.)
837
838 </P>
839 <P>
840 This particular issue has been strongly debated in the GNU
841 <CODE>gettext</CODE> development forum, and it is expectable that MO file
842 format will evolve or change over time.  It is even possible that many
843 formats may later be supported concurrently.  But surely, we have to
844 start somewhere, and the MO file format described here is a good start.
845 Nothing is cast in concrete, and the format may later evolve fairly
846 easily, so we should feel comfortable with the current approach.
847
848 </P>
849
850 <PRE>
851         byte
852              +------------------------------------------+
853           0  | magic number = 0x950412de                |
854              |                                          |
855           4  | file format revision = 0                 |
856              |                                          |
857           8  | number of strings                        |  == N
858              |                                          |
859          12  | offset of table with original strings    |  == O
860              |                                          |
861          16  | offset of table with translation strings |  == T
862              |                                          |
863          20  | size of hashing table                    |  == S
864              |                                          |
865          24  | offset of hashing table                  |  == H
866              |                                          |
867              .                                          .
868              .    (possibly more entries later)         .
869              .                                          .
870              |                                          |
871           O  | length &#38; offset 0th string  ----------------.
872       O + 8  | length &#38; offset 1st string  ------------------.
873               ...                                    ...   | |
874 O + ((N-1)*8)| length &#38; offset (N-1)th string           |  | |
875              |                                          |  | |
876           T  | length &#38; offset 0th translation  ---------------.
877       T + 8  | length &#38; offset 1st translation  -----------------.
878               ...                                    ...   | | | |
879 T + ((N-1)*8)| length &#38; offset (N-1)th translation      |  | | | |
880              |                                          |  | | | |
881           H  | start hash table                         |  | | | |
882               ...                                    ...   | | | |
883   H + S * 4  | end hash table                           |  | | | |
884              |                                          |  | | | |
885              | NUL terminated 0th string  &#60;----------------' | | |
886              |                                          |    | | |
887              | NUL terminated 1st string  &#60;------------------' | |
888              |                                          |      | |
889               ...                                    ...       | |
890              |                                          |      | |
891              | NUL terminated 0th translation  &#60;---------------' |
892              |                                          |        |
893              | NUL terminated 1st translation  &#60;-----------------'
894              |                                          |
895               ...                                    ...
896              |                                          |
897              +------------------------------------------+
898 </PRE>
899
900 <P><HR><P>
901 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>.
902 </BODY>
903 </HTML>