msgfmt creates message object files from portable object files (filename.po ), without changing the portable object files.
The .po file contains messages displayed to users by system commands or by application programs. .po files can be edited, and the messages in them can be rewritten in any language supported by the system.
The xgettext(1) command can be used to create .po files from script or programs.
msgfmt interprets data as characters according to the current setting of the LC_CTYPE locale category.
Formats for all .po files are the same. Each .po file contains one or more lines, with each line containing either a comment or a statement. Comments start the line with a hash mark (#) and end with the newline character. All comments are ignored. The format of a statement is:
Each directive starts at the beginning of the line and is separated from value by white space (such as one or more space or tab characters). value consists of one or more quoted strings separated by white space. Use any of the following types of directives:
domain domainname
msgid message_identifier
msgstr message_string
The behavior of the domain directive is affected by the options used. See OPTIONS for the behavior when the -o option is specified. If the -o option is not specified, the behavior of the domain directive is as follows:
·
- All msgids from the beginning of each .po file to the first domain directive are put into a default message object file, messages.mo.
·- When msgfmt encounters a domain domainname directive in the .po file, all following msgids until the next domain directive are put into the message object file
·- Duplicate msgids are defined in the scope of each domain. That is, a msgid is considered a duplicate only if the identical msgid exists in the same domain.
·- All duplicate msgids are ignored.
The msgid directive specifies the value of a message identifier associated with the directive that follows it. The message_identifier string identifies a target string to be used at retrieval time. Each statement containing a msgid directive must be followed by a statement containing a msgstr directive.
The msgstr directive specifies the target string associated with the message_identifier string declared in the immediately preceding msgid directive.
Message strings can contain the escape sequences \n for newline, \t for tab, \v for vertical tab, \b for backspace, \r for carriage return, \f for formfeed, \\ for backslash, \" for double quote, \ddd for octal bit pattern, and \xDD for hexadecimal bit pattern.
example% cat module1.po
# default domain "messages.mo"
msgid "msg 1"
msgstr "msg 1 translation"
#
domain "help_domain"
msgid "help 2"
msgstr "help 2 translation"
#
domain "error_domain"
msgid "error 3"
msgstr "error 3 translation"
example% cat module2.po
# default domain "messages.mo"
msgid "mesg 4"
msgstr "mesg 4 translation"
#
domain "error_domain"
msgid "error 5"
msgstr "error 5 translation"
#
domain "window_domain"
msgid "window 6"
msgstr "window 6 translation"
The following command will produce the output files, messages.mo, help_domain.mo, and error_domain.mo.
The following command will produce the output files, messages.mo, help_domain.mo, error_domain.mo, and window_domain.mo.
The following example will produce the output file hello.mo.
Install message object files in /usr/lib/locale/locale/LC_MESSAGES/ domain.mo where locale is the message locale as set by setlocale(3C) , and domain is text domain as set by textdomain(). The /usr/lib/locale portion can optionally be changed by calling bindtextdomain(). See gettext(3C) .
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Availability | SUNWloc |
CSI | Enabled |
Neither msgfmt nor any gettext() routine imposes a limit on the total length of a message. However, each line in the *.po file is limited to MAX_INPUT (512) bytes.
Installing message catalogs under the C locale is pointless, since they are ignored for the sake of efficiency.