Next: , Previous: Binaries, Up: Binaries   [Contents][Index]


10.1 Invoking the msgfmt Program

msgfmt [option] filename.po …

The msgfmt programs generates a binary message catalog from a textual translation description.

10.1.1 Input file location

filename.po …
-D directory
--directory=directory

Add 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.

If an input file is ‘-’, standard input is read.

10.1.2 Operation mode

-j
--java

Java mode: generate a Java ResourceBundle class.

--java2

Like –java, and assume Java2 (JDK 1.2 or higher).

--csharp

C# mode: generate a .NET .dll file containing a subclass of GettextResourceSet.

--csharp-resources

C# resources mode: generate a .NET .resources file.

--tcl

Tcl mode: generate a tcl/msgcat .msg file.

--qt

Qt mode: generate a Qt .qm file.

--desktop

Desktop Entry mode: generate a .desktop file.

10.1.3 Output file location

-o file
--output-file=file

Write output to specified file.

--strict

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 .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 not selected.

If the output file is ‘-’, output is written to standard output.

10.1.4 Output file location in Java mode

-r resource
--resource=resource

Specify the resource name.

-l locale
--locale=locale

Specify the locale name, either a language specification of the form ll or a combined language and country specification of the form ll_CC.

-d directory

Specify the base directory of classes directory hierarchy.

--source

Produce a .java source file, instead of a compiled .class file.

The class name is determined by appending the locale name to the resource name, separated with an underscore. The ‘-d’ option is mandatory. The class is written under the specified directory.

10.1.5 Output file location in C# mode

-r resource
--resource=resource

Specify the resource name.

-l locale
--locale=locale

Specify the locale name, either a language specification of the form ll or a combined language and country specification of the form ll_CC.

-d directory

Specify the base directory for locale dependent .dll files.

The ‘-l’ and ‘-d’ options are mandatory. The .dll file is written in a subdirectory of the specified directory whose name depends on the locale.

10.1.6 Output file location in Tcl mode

-l locale
--locale=locale

Specify the locale name, either a language specification of the form ll or a combined language and country specification of the form ll_CC.

-d directory

Specify the base directory of .msg message catalogs.

The ‘-l’ and ‘-d’ options are mandatory. The .msg file is written in the specified directory.

10.1.7 Desktop Entry mode operations

--template=template

Specify a .desktop file used as a template.

-k[keywordspec]
--keyword[=keywordspec]

Specify keywordspec as an additional keyword to be looked for. Without a keywordspec, the option means to not use default keywords.

-l locale
--locale=locale

Specify the locale name, either a language specification of the form ll or a combined language and country specification of the form ll_CC.

-d directory

Specify the base directory of .msg message catalogs.

To generate a ‘.desktop’ file for a single locale, you can use it as follows.

msgfmt --desktop --template=template --locale=locale \
  -o file filename.po …

On the other hand, when using msgfmt from a Makefile, it is cumbersome to loop over all locales under a particular directory. msgfmt provides a special operation mode for this use-case. To generate a ‘.desktop’ file from multiple ‘.po’ files under a directory, specify the directory with the ‘-d’ option.

msgfmt --desktop --template=template -d directory -o file

msgfmt first reads the ‘LINGUAS’ file under directory, and then processes all ‘.po’ files listed there. You can also limit the locales to a subset, through the ‘LINGUAS’ environment variable.

For either operation modes, the ‘-o’ and ‘--template’ options are mandatory.

10.1.8 Input file syntax

-P
--properties-input

Assume the input files are Java ResourceBundles in Java .properties syntax, not in PO file syntax.

--stringtable-input

Assume the input files are NeXTstep/GNUstep localized resource files in .strings syntax, not in PO file syntax.

10.1.9 Input file interpretation

-c
--check

Perform all the checks implied by --check-format, --check-header, --check-domain.

--check-format

Check language dependent format strings.

If the string represents a format string used in a printf-like function both strings should have the same number of ‘%’ format specifiers, with matching types. If the flag c-format or possible-c-format appears in the special comment #, for this entry a check is performed. For example, the check will diagnose using ‘%.*s’ against ‘%s’, or ‘%d’ against ‘%s’, or ‘%d’ against ‘%x’. It can even handle positional parameters.

Normally the 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 printf-like function and so msgfmt might report errors where there are none.

To solve this problem the programmer can dictate the decision to the xgettext program (see c-format). The translator should not consider removing the flag from the #, line. This "fix" would be reversed again as soon as msgmerge is called the next time.

--check-header

Verify presence and contents of the header entry. See Header Entry, for a description of the various fields in the header entry.

--check-domain

Check for conflicts between domain directives and the --output-file option

-C
--check-compatibility

Check that GNU msgfmt behaves like X/Open msgfmt. This will give an error when attempting to use the GNU extensions.

--check-accelerators[=char]

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 ‘&’ character. Sometimes a keyboard accelerator is also called "keyboard mnemonic". This check verifies that if the untranslated string has exactly one ‘&’ character, the translated string has exactly one ‘&’ as well. If this option is given with a char argument, this char should be a non-alphanumeric character and is used as keyboard accelerator mark instead of ‘&’.

-f
--use-fuzzy

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.

10.1.10 Output details

-a number
--alignment=number

Align strings to number bytes (default: 1).

--endianness=byteorder

Write out 32-bit numbers in the given byte order. The possible values are big and little. The default depends on the platform, namely on the endianness of the CPU.

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 independent of the platform.

--no-hash

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).

10.1.11 Informative output

-h
--help

Display this help and exit.

-V
--version

Output version information and exit.

--statistics

Print statistics about translations. When the option --verbose is used in combination with --statistics, the input file name is printed in front of the statistics line.

-v
--verbose

Increase verbosity level.


Next: , Previous: Binaries, Up: Binaries   [Contents][Index]