• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@c This file is part of the GNU gettext manual.
2@c Copyright (C) 1995-2019 Free Software Foundation, Inc.
3@c See the file gettext.texi for copying conditions.
4
5@pindex msgfmt
6@cindex @code{msgfmt} program, usage
7@example
8msgfmt [@var{option}] @var{filename}.po @dots{}
9@end example
10
11@cindex generate binary message catalog from PO file
12The @code{msgfmt} programs generates a binary message catalog from a textual
13translation description.
14
15@subsection Input file location
16
17@table @samp
18@item @var{filename}.po @dots{}
19
20@item -D @var{directory}
21@itemx --directory=@var{directory}
22@opindex -D@r{, @code{msgfmt} option}
23@opindex --directory@r{, @code{msgfmt} option}
24Add @var{directory} to the list of directories.  Source files are
25searched relative to this list of directories.  The resulting binary
26file will be written relative to the current directory, though.
27
28@end table
29
30If an input file is @samp{-}, standard input is read.
31
32@subsection Operation mode
33
34@table @samp
35@item -j
36@itemx --java
37@opindex -j@r{, @code{msgfmt} option}
38@opindex --java@r{, @code{msgfmt} option}
39@cindex Java mode, and @code{msgfmt} program
40Java mode: generate a Java @code{ResourceBundle} class.
41
42@item --java2
43@opindex --java2@r{, @code{msgfmt} option}
44Like --java, and assume Java2 (JDK 1.2 or higher).
45
46@item --csharp
47@opindex --csharp@r{, @code{msgfmt} option}
48@cindex C# mode, and @code{msgfmt} program
49C# mode: generate a .NET .dll file containing a subclass of
50@code{GettextResourceSet}.
51
52@item --csharp-resources
53@opindex --csharp-resources@r{, @code{msgfmt} option}
54@cindex C# resources mode, and @code{msgfmt} program
55C# resources mode: generate a .NET @file{.resources} file.
56
57@item --tcl
58@opindex --tcl@r{, @code{msgfmt} option}
59@cindex Tcl mode, and @code{msgfmt} program
60Tcl mode: generate a tcl/msgcat @file{.msg} file.
61
62@item --qt
63@opindex --qt@r{, @code{msgfmt} option}
64@cindex Qt mode, and @code{msgfmt} program
65Qt mode: generate a Qt @file{.qm} file.
66
67@item --desktop
68@opindex --desktop@r{, @code{msgfmt} option}
69@cindex Desktop Entry mode, and @code{msgfmt} program
70Desktop Entry mode: generate a @file{.desktop} file.
71
72@item --xml
73@opindex --xml@r{, @code{msgfmt} option}
74@cindex XML mode, and @code{msgfmt} program
75XML mode: generate an XML file.
76
77@end table
78
79@subsection Output file location
80
81@table @samp
82@item -o @var{file}
83@itemx --output-file=@var{file}
84@opindex -o@r{, @code{msgfmt} option}
85@opindex --output-file@r{, @code{msgfmt} option}
86Write output to specified file.
87
88@item --strict
89@opindex --strict@r{, @code{msgfmt} option}
90Direct the program to work strictly following the Uniforum/Sun
91implementation.  Currently this only affects the naming of the output
92file.  If this option is not given the name of the output file is the
93same as the domain name.  If the strict Uniforum mode is enabled the
94suffix @file{.mo} is added to the file name if it is not already
95present.
96
97We find this behaviour of Sun's implementation rather silly and so by
98default this mode is @emph{not} selected.
99
100@end table
101
102If the output @var{file} is @samp{-}, output is written to standard output.
103
104@subsection Output file location in Java mode
105
106@table @samp
107@item -r @var{resource}
108@itemx --resource=@var{resource}
109@opindex -r@r{, @code{msgfmt} option}
110@opindex --resource@r{, @code{msgfmt} option}
111Specify the resource name.
112
113@item -l @var{locale}
114@itemx --locale=@var{locale}
115@opindex -l@r{, @code{msgfmt} option}
116@opindex --locale@r{, @code{msgfmt} option}
117Specify the locale name, either a language specification of the form @var{ll}
118or a combined language and country specification of the form @var{ll_CC}.
119
120@item -d @var{directory}
121@opindex -d@r{, @code{msgfmt} option}
122Specify the base directory of classes directory hierarchy.
123
124@item --source
125@opindex --source@r{, @code{msgfmt} option}
126Produce a .java source file, instead of a compiled .class file.
127
128@end table
129
130The class name is determined by appending the locale name to the resource name,
131separated with an underscore.  The @samp{-d} option is mandatory.  The class
132is written under the specified directory.
133
134@subsection Output file location in C# mode
135
136@table @samp
137@item -r @var{resource}
138@itemx --resource=@var{resource}
139@opindex -r@r{, @code{msgfmt} option}
140@opindex --resource@r{, @code{msgfmt} option}
141Specify the resource name.
142
143@item -l @var{locale}
144@itemx --locale=@var{locale}
145@opindex -l@r{, @code{msgfmt} option}
146@opindex --locale@r{, @code{msgfmt} option}
147Specify the locale name, either a language specification of the form @var{ll}
148or a combined language and country specification of the form @var{ll_CC}.
149
150@item -d @var{directory}
151@opindex -d@r{, @code{msgfmt} option}
152Specify the base directory for locale dependent @file{.dll} files.
153
154@end table
155
156The @samp{-l} and @samp{-d} options are mandatory.  The @file{.dll} file is
157written in a subdirectory of the specified directory whose name depends on the
158locale.
159
160@subsection Output file location in Tcl mode
161
162@table @samp
163@item -l @var{locale}
164@itemx --locale=@var{locale}
165@opindex -l@r{, @code{msgfmt} option}
166@opindex --locale@r{, @code{msgfmt} option}
167Specify the locale name, either a language specification of the form @var{ll}
168or a combined language and country specification of the form @var{ll_CC}.
169
170@item -d @var{directory}
171@opindex -d@r{, @code{msgfmt} option}
172Specify the base directory of @file{.msg} message catalogs.
173
174@end table
175
176The @samp{-l} and @samp{-d} options are mandatory.  The @file{.msg} file is
177written in the specified directory.
178
179@subsection Desktop Entry mode operations
180
181@table @samp
182@item --template=@var{template}
183@opindex --template@r{, @code{msgfmt} option}
184Specify a .desktop file used as a template.
185
186@item -k[@var{keywordspec}]
187@itemx --keyword[=@var{keywordspec}]
188@opindex -k@r{, @code{msgfmt} option}
189@opindex --keyword@r{, @code{msgfmt} option}
190Specify @var{keywordspec} as an additional keyword to be looked for.
191Without a @var{keywordspec}, the option means to not use default keywords.
192
193@item -l @var{locale}
194@itemx --locale=@var{locale}
195@opindex -l@r{, @code{msgfmt} option}
196@opindex --locale@r{, @code{msgfmt} option}
197Specify the locale name, either a language specification of the form @var{ll}
198or a combined language and country specification of the form @var{ll_CC}.
199
200@item -d @var{directory}
201@opindex -d@r{, @code{msgfmt} option}
202Specify the directory where PO files are read.  The directory must
203contain the @samp{LINGUAS} file.
204
205@end table
206
207To generate a @samp{.desktop} file for a single locale, you can use it
208as follows.
209
210@example
211msgfmt --desktop --template=@var{template} --locale=@var{locale} \
212  -o @var{file} @var{filename}.po @dots{}
213@end example
214
215msgfmt provides a special "bulk" operation mode to process multiple
216@file{.po} files at a time.
217
218@example
219msgfmt --desktop --template=@var{template} -d @var{directory} -o @var{file}
220@end example
221
222msgfmt first reads the @samp{LINGUAS} file under @var{directory}, and
223then processes all @samp{.po} files listed there.  You can also limit
224the locales to a subset, through the @samp{LINGUAS} environment
225variable.
226
227For either operation modes, the @samp{-o} and @samp{--template}
228options are mandatory.
229
230@subsection XML mode operations
231
232@table @samp
233@item --template=@var{template}
234@opindex --template@r{, @code{msgfmt} option}
235Specify an XML file used as a template.
236
237@item -L @var{name}
238@itemx --language=@var{name}
239@opindex -L@r{, @code{msgfmt} option}
240@opindex --language@r{, @code{msgfmt} option}
241@cindex supported languages, @code{msgfmt}
242Specifies the language of the input files.
243
244@item -l @var{locale}
245@itemx --locale=@var{locale}
246@opindex -l@r{, @code{msgfmt} option}
247@opindex --locale@r{, @code{msgfmt} option}
248Specify the locale name, either a language specification of the form @var{ll}
249or a combined language and country specification of the form @var{ll_CC}.
250
251@item -d @var{directory}
252@opindex -d@r{, @code{msgfmt} option}
253Specify the base directory of @file{.po} message catalogs.
254
255@end table
256
257To generate an XML file for a single locale, you can use it as follows.
258
259@example
260msgfmt --xml --template=@var{template} --locale=@var{locale} \
261  -o @var{file} @var{filename}.po @dots{}
262@end example
263
264msgfmt provides a special "bulk" operation mode to process multiple
265@file{.po} files at a time.
266
267@example
268msgfmt --xml --template=@var{template} -d @var{directory} -o @var{file}
269@end example
270
271msgfmt first reads the @samp{LINGUAS} file under @var{directory}, and
272then processes all @samp{.po} files listed there.  You can also limit
273the locales to a subset, through the @samp{LINGUAS} environment
274variable.
275
276For either operation modes, the @samp{-o} and @samp{--template}
277options are mandatory.
278
279@subsection Input file syntax
280
281@table @samp
282@item -P
283@itemx --properties-input
284@opindex -P@r{, @code{msgfmt} option}
285@opindex --properties-input@r{, @code{msgfmt} option}
286Assume the input files are Java ResourceBundles in Java @code{.properties}
287syntax, not in PO file syntax.
288
289@item --stringtable-input
290@opindex --stringtable-input@r{, @code{msgfmt} option}
291Assume the input files are NeXTstep/GNUstep localized resource files in
292@code{.strings} syntax, not in PO file syntax.
293
294@end table
295
296@subsection Input file interpretation
297
298@table @samp
299@item -c
300@itemx --check
301@opindex -c@r{, @code{msgfmt} option}
302@opindex --check@r{, @code{msgfmt} option}
303Perform all the checks implied by @code{--check-format}, @code{--check-header},
304@code{--check-domain}.
305
306@item --check-format
307@opindex --check-format@r{, @code{msgfmt} option}
308@cindex check format strings
309Check language dependent format strings.
310
311If the string represents a format string used in a
312@code{printf}-like function both strings should have the same number of
313@samp{%} format specifiers, with matching types.  If the flag
314@code{c-format} or @code{possible-c-format} appears in the special
315comment @key{#,} for this entry a check is performed.  For example, the
316check will diagnose using @samp{%.*s} against @samp{%s}, or @samp{%d}
317against @samp{%s}, or @samp{%d} against @samp{%x}.  It can even handle
318positional parameters.
319
320Normally the @code{xgettext} program automatically decides whether a
321string is a format string or not.  This algorithm is not perfect,
322though.  It might regard a string as a format string though it is not
323used in a @code{printf}-like function and so @code{msgfmt} might report
324errors where there are none.
325
326To solve this problem the programmer can dictate the decision to the
327@code{xgettext} program (@pxref{c-format}).  The translator should not
328consider removing the flag from the @key{#,} line.  This "fix" would be
329reversed again as soon as @code{msgmerge} is called the next time.
330
331@item --check-header
332@opindex --check-header@r{, @code{msgfmt} option}
333Verify presence and contents of the header entry.  @xref{Header Entry},
334for a description of the various fields in the header entry.
335
336@item --check-domain
337@opindex --check-domain@r{, @code{msgfmt} option}
338Check for conflicts between domain directives and the @code{--output-file}
339option
340
341@item -C
342@itemx --check-compatibility
343@opindex -C@r{, @code{msgfmt} option}
344@opindex --check-compatibility@r{, @code{msgfmt} option}
345@cindex compatibility with X/Open @code{msgfmt}
346Check that GNU msgfmt behaves like X/Open msgfmt.  This will give an error
347when attempting to use the GNU extensions.
348
349@item --check-accelerators[=@var{char}]
350@opindex --check-accelerators@r{, @code{msgfmt} option}
351@cindex keyboard accelerator checking
352@cindex menu, keyboard accelerator support
353@cindex mnemonics of menu entries
354Check presence of keyboard accelerators for menu items.  This is based on
355the convention used in some GUIs that a keyboard accelerator in a menu
356item string is designated by an immediately preceding @samp{&} character.
357Sometimes a keyboard accelerator is also called "keyboard mnemonic".
358This check verifies that if the untranslated string has exactly one
359@samp{&} character, the translated string has exactly one @samp{&} as well.
360If this option is given with a @var{char} argument, this @var{char} should
361be a non-alphanumeric character and is used as keyboard accelerator mark
362instead of @samp{&}.
363
364@item -f
365@itemx --use-fuzzy
366@opindex -f@r{, @code{msgfmt} option}
367@opindex --use-fuzzy@r{, @code{msgfmt} option}
368@cindex force use of fuzzy entries
369Use fuzzy entries in output.  Note that using this option is usually wrong,
370because fuzzy messages are exactly those which have not been validated by
371a human translator.
372
373@end table
374
375@subsection Output details
376
377@table @samp
378@item -a @var{number}
379@itemx --alignment=@var{number}
380@opindex -a@r{, @code{msgfmt} option}
381@opindex --alignment@r{, @code{msgfmt} option}
382Align strings to @var{number} bytes (default: 1).
383@c Currently the README mentions that this constant could be changed by
384@c the installer by changing the value in config.h.  Should this go away?
385
386@item --endianness=@var{byteorder}
387@opindex --endianness@r{, @code{msgfmt} option}
388Write out 32-bit numbers in the given byte order.  The possible values are
389@code{big} and @code{little}.  The default is @code{little}.
390
391MO files of any endianness can be used on any platform.  When a MO file has
392an endianness other than the platform's one, the 32-bit numbers from the MO
393file are swapped at runtime.  The performance impact is negligible.
394
395This option can be useful to produce MO files that are optimized for one
396platform.
397
398@item --no-hash
399@opindex --no-hash@r{, @code{msgfmt} option}
400Don't include a hash table in the binary file.  Lookup will be more expensive
401at run time (binary search instead of hash table lookup).
402
403@end table
404
405@subsection Informative output
406
407@table @samp
408@item -h
409@itemx --help
410@opindex -h@r{, @code{msgfmt} option}
411@opindex --help@r{, @code{msgfmt} option}
412Display this help and exit.
413
414@item -V
415@itemx --version
416@opindex -V@r{, @code{msgfmt} option}
417@opindex --version@r{, @code{msgfmt} option}
418Output version information and exit.
419
420@item --statistics
421@opindex --statistics@r{, @code{msgfmt} option}
422Print statistics about translations.  When the option @code{--verbose} is used
423in combination with @code{--statistics}, the input file name is printed in
424front of the statistics line.
425
426@item -v
427@itemx --verbose
428@opindex -v@r{, @code{msgfmt} option}
429@opindex --verbose@r{, @code{msgfmt} option}
430Increase verbosity level.
431
432@end table
433