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