msgfmt β generate binary message catalog from textual translation description
| Use Case | Command | Description |
|---|---|---|
| π Create standard .mo file | msgfmt -o output.mo input.po | Compile a .po file into a binary .mo catalog |
| β Generate Java ResourceBundle class | msgfmt -j --resource=Messages -l de_DE -d classes input.po | Create a compiled Java class for locale |
| #οΈβ£ Produce .NET .dll | msgfmt --csharp -r Messages -l fr -d bin input.po | Generate C# satellite assembly |
| π₯οΈ Generate .desktop file | msgfmt --desktop --template=app.desktop -l de -o app.de.desktop de.po | Create a localised .desktop entry |
| π Create XML translation file | msgfmt --xml --template=doc.xml -l es -o doc.es.xml es.po | Produce localised XML document |
| π Validate translations | msgfmt -c input.po | Check format strings, header, and domain consistency |
| π View translation statistics | msgfmt --statistics -v input.po | Print number of translated, fuzzy, untranslated messages |
msgfmt [OPTION] FILENAME.po ...
The msgfmt program generates a binary message catalog from a textual translation description.
FILENAME.po ...-D DIRECTORY / --directory=DIRECTORY β π Add DIRECTORY to the list of directories. Source files are searched relative to this list. The resulting binary file will be written relative to the current directory, though.If an input file is -, standard input is read.
-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.--xml β π XML mode: generate an XML file.-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.
-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.
-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.
-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.
--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 directory where PO files are read. The directory must contain the LINGUAS file.To generate a .desktop file for a single locale:
msgfmt --desktop --template=TEMPLATE --locale=LOCALE \
-o FILE FILENAME.po ...
Bulk mode (process multiple .po files):
msgfmt --desktop --template=TEMPLATE -d DIRECTORY -o FILE
msgfmt first reads the LINGUAS file under DIRECTORY, then processes all .po files listed there. You can also limit the locales to a subset through the LINGUAS environment variable. For either operation mode, the -o and --template options are mandatory.
--template=TEMPLATE β π Specify an XML file used as a template.-L NAME / --language=NAME β π Specifies the language of the input files.-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 .po message catalogs.Single locale:
msgfmt --xml --template=TEMPLATE --locale=LOCALE \
-o FILE FILENAME.po ...
Bulk mode:
msgfmt --xml --template=TEMPLATE -d DIRECTORY -o FILE
Same LINGUAS file processing as desktop mode. -o and --template are mandatory.
-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.-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. 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.--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.-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 is 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.--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).-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.Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 04:54 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format