User Commands msgfmt(1)
NAME
msgfmt - create a message object from a message file
SYNOPSIS
msgfmt [-D dir | --directory=dir]
[-f | --use-fuzzy] [-g]
[-o output-file | --output-file=output-file]
[-s] [--strict] [-v] [--verbose] filename.po...
DESCRIPTION
The msgfmt utility creates message object files from port-
able object files (filename.po), without changing the port-
able object files. The .po file contains messages displayed to users by system commands or by application programs. .po files can be edited. The messages in these files 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 or according
to the codeset specified in the .po file. OPTIONS The following options are supported:-D dir Adds dir to the list for input
--directory=dir files search.
-f Uses fuzzy entries in output. If
--use-fuzzy this option is not specified,
fuzzy entries are not included into the output. These options are ignored if Solaris message catalogs are processed.-g Directs the utility to generate
the GNU-compatible message cata-
log file. This option cannot bespecified with the -s option.
SunOS 5.11 Last change: 17 Sep 2001 1
User Commands msgfmt(1)
-o output-file Specifies the output file name as
--output=output-file output-file. All domain direc-
tives and duplicate msgids in the .po file are ignored.-s Directs the utility to generate
the Solaris message catalog file. This option cannot be specifiedwith the -g option.
--strict Directs the utility to append the
suffix .mo to the generating mes-
sage object file name if it doesn't have this suffix. Thisoption is ignored if Solaris mes-
sage catalogs are processed.-v Verbose. Lists duplicate message
--verbose identifiers if Solaris message
catalog files are processed. Mes-
sage strings are not redefined.If GNU-compatible message files
are processed, this option detects and diagnoses input file anomalies which might represent translation errors. The msgid and msgstr strings are studied andcompared. It is considered abnor-
mal if one string starts or ends with a newline while the other does not. Also, if the string represents a format string usedin a printf-like function, both
strings should have the samenumber of % format specifiers,
with matching types. If the flagc-format appears in the special
comment '#' for this entry, a
check is performed.USAGE
The format of portable object files (.po files) is defined as follows. Each .po file contains one or more lines, witheach line containing either a comment or a statement. Com-
ments start the line with a pound sign (#) and end with the
newline character. All comments (except special comments described later) and empty lines are ignored. The format ofSunOS 5.11 Last change: 17 Sep 2001 2
User Commands msgfmt(1)
a statement is: directive value 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 morequoted strings separated by white space. Use any of the fol-
lowing types of directives for the Solaris message file: domain domainnamemsgid message_identifier
msgstr message_string
For a GNU-compatible message file, use any of the following
types of directives: domain domainnamemsgid message_identifier
msgid_plural untranslated_string_plural
msgstr message_string
msgstr[n] message_string
The behavior of the domain directive is affected by theoptions used. See OPTIONS for the behavior when the -o or
--output-file options are specified. If the -o or --output-
file options are not specified, the behavior of the domain directive is as follows: o All msgids from the beginning of each .po file to the first domain directive are put into a default message object file. The default message object file is named messages.mo, if the Solaris message catalog file format is used to generate the messageobject file or if the --strict option is specified.
Otherwise, the default message object file is named messages.o When msgfmt encounters a domain domainname direc-
tive in the .po file, all following msgids until the next domain directive are put into the message object file, named domainname.mo, if the Solaris message catalog file format is used to generate theSunOS 5.11 Last change: 17 Sep 2001 3
User Commands msgfmt(1)
message object file or if the --strict option is
specified. Otherwise, the msgids are put into the message object file named domainname. o 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. o All duplicate msgids are ignored.The msgid directive specifies the value of a message iden-
tifier associated with the directive that follows it. Themsgid_plural directive specifies the plural form message
specified to the plural message handling functions nget-
text(), dngettext(), or dcngettext(). 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 or msgstr[n] directives. The msgstr directive specifies the target string associatedwith the message_identifier string declared in the immedi-
ately preceding msgid directive. The directive msgstr[n] (where n = 0, 1, 2, ...) specifiesthe target string to be used with plural form handling func-
tions ngettext(), dngettext(), and dcngetttext().Message strings can contain the escafpe sequencesfor0ocrarrnieawg-e
lrienteu,rn, ffoorr tfaobr,mfoeredv,er\tifcoarl tbaabc,ksolbaaschk,space, rComments for a GNU-compatible message file should be in one
of the following formats (the msgfmt utility will ignore
these comments when processing Solaris message files):# translator-comments
#. automatic-comments
#: reference..
#, flag
The '#:' comments indicate the location of the msgid string
in the source files in filename:line format. The '#', '#.',
SunOS 5.11 Last change: 17 Sep 2001 4
User Commands msgfmt(1)
and '#:' comments are informative only and are silently
ignored by the msgfmt utility. The '#,' comments require one
or more flags separated by the comma character. The follow-
ing flags can be specified: fuzzy This flag can be inserted by the translator. It shows that the msgstr string might not be a correct translation (anymore). Only the translator can judge if the translationrequires further modification or is accept-
able as is. Once satisfied with the transla-
tion, the translator removes this fuzzy flag.If this flag is specified, the msgfmt utility
will not generate the entry for the immedi-
ately following msgid in the output message catalog.c-format The c-format flag indicates that the msgid
no-c-format string is used as a format string by printf-
like functions. In case the c-format flag is
given for a string, the msgfmt utility does
some more tests to check the validity of the translation.In the GNU-compatible message file, the msgid entry with
empty string ("") is called the header entry and treatedspecially. If the message string for the header entry con-
tains nplurals=value, the value indicates the number of plural forms. For example, if nplurals=4, there are four plural forms. If nplurals is defined, the same line shouldcontain plural=expression, separated by a semicolon charac-
ter. The expression is a C language expression to determine which version of msgstr[n] is to be used based on the value of n, the last argument of ngettext(), dngettext(), or dcngettext(). For example, nplurals=2; plural= n == 1 ? 0 : 1 indicates that there are two plural forms in the language. msgstr[0] is used if n == 1, otherwise msgstr[1] is used. For another example: nplurals=3; plural= n == 1 ? 0 : n == 2 ? 1 : 2SunOS 5.11 Last change: 17 Sep 2001 5
User Commands msgfmt(1)
indicates that there are three plural forms in the language. msgstr[0] is used if n == 1, msgstr[1] is used if n == 2, otherwise msgstr[2] is used. If the header entry contains a charset=codeset string, the codeset is used to indicate the codeset to be used to encodethe message strings. If the output string's codeset is dif-
ferent from the message string's codeset, codeset conversion from the message string's codeset to the output string'scodeset will be performed upon the call of gettext(), dget-
text(), dcgettext(), ngettext(), dngettext(), and dcnget-
text() for the GNU-compatible message catalogs. The output
string's codeset is determined by the current locale'scodeset (the return value of nl_langinfo(CODESET)) by
default, and can be changed by the call ofbind_textdomain_codeset().
Message catalog file formatThe msgfmt utility can generate the message object both in
Solaris message catalog file format and in GNU-compatible
message catalog file format. If the -s option is specified
and the input file is a Solaris .po file, the msgfmt utility
generates the message object in Solaris message catalog fileformat. If the -g option is specified and the input file is
a GNU .po file, the msgfmt utility generates the message
object in GNU-compatible message catalog file format. If
neither the -s nor -g option is specified, the msgfmt util-
ity determines the message catalog file format as follows: o If the .po file contains a valid GNU header entry(having an empty string for msgid), the msgfmt
utility uses the GNU-compatible message catalog
file format.o Otherwise, the msgfmt utility uses the Solaris mes-
sage catalog file format.If the msgfmt utility determined that the Solaris message
catalog file format is used, as above, but found the .pofile contains directives that are specific to the GNU-
compatible message catalog file format, such as msgid_plural
and msgstr[n], the msgfmt utility handles those directives
as invalid specifications.EXAMPLES
Example 1 Creating message objects from message filesIn this example, module1.po and module2.po are portable mes-
sage objects files.SunOS 5.11 Last change: 17 Sep 2001 6
User Commands msgfmt(1)
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 filesmessages.mo, help_domain.mo, and error_domain.mo in Solaris
message catalog file format:example% msgfmt module1.po
The following command will produce the output filesmessages.mo, help_domain.mo, error_domain.mo, and
window_domain.mo in Solaris message catalog file format:
example% msgfmt module1.po module2.po
The following command will produce the output file hello.mo in Solaris message catalog file format:SunOS 5.11 Last change: 17 Sep 2001 7
User Commands msgfmt(1)
example% msgfmt -o hello.mo module1.po module2.po
ENVIRONMENT VARIABLESSee environ(5) for descriptions of the following environmen-
tal variables that affect the execution of msgfmt: LC_CTYPE,
LC_MESSAGES, and NLSPATH.
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | text/locale ||_____________________________|_____________________________|
| CSI | Enabled ||_____________________________|_____________________________|
SEE ALSO
xgettext(1), gettext(3C), setlocale(3C), attributes(5), environ(5) NOTES Installing message catalogs under the C locale is pointless, since they are ignored for the sake of efficiency.SunOS 5.11 Last change: 17 Sep 2001 8