2 .\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MSGFMT 1 "Sep 17, 2001"
8 msgfmt \- create a message object from a message file
12 \fBmsgfmt\fR [\fB-D\fR \fIdir\fR | \fB-\(midirectory\fR=\fIdir\fR]
13 [\fB-f\fR | \fB-\(miuse-fuzzy\fR] [\fB-g\fR]
14 [\fB-o\fR \fIoutput-file\fR | \fB-\(mioutput-file\fR=\fIoutput-file\fR]
15 [\fB-s\fR] [\fB-\(mistrict\fR] [\fB-v\fR] [\fB-\(miverbose\fR] \fIfilename\fR.po...
21 The \fBmsgfmt\fR utility creates message object files from portable object
22 files (\fIfilename\fR\fB\&.po\fR), without changing the portable object files.
25 The \fB\&.po\fR file contains messages displayed to users by system commands or
26 by application programs. \fB\&.po\fR files can be edited. The messages in these
27 files can be rewritten in any language supported by the system.
30 The \fBxgettext\fR(1) command can be used to create \fB\&.po\fR files from
34 \fBmsgfmt\fR interprets data as characters according to the current setting of
35 the \fBLC_CTYPE\fR locale category or according to the codeset specified in the
40 The following options are supported:
44 \fB\fB-D\fR \fIdir\fR\fR
48 \fB\fB-\(midirectory=\fR\fIdir\fR\fR
51 Adds \fIdir\fR to the list for input files search.
61 \fB\fB-\(miuse-fuzzy\fR\fR
64 Uses fuzzy entries in output. If this option is not specified, fuzzy entries
65 are not included into the output. These options are ignored if Solaris message
66 catalogs are processed.
75 Directs the utility to generate the GNU-compatible message catalog file. This
76 option cannot be specified with the \fB-s\fR option.
82 \fB\fB-o\fR \fIoutput-file\fR\fR
86 \fB\fB-\(mioutput=\fR\fIoutput-file\fR\fR
89 Specifies the output file name as \fIoutput-file\fR. All domain directives and
90 duplicate msgids in the .\fBpo\fR file are ignored.
99 Directs the utility to generate the Solaris message catalog file. This option
100 cannot be specified with the \fB-g\fR option.
106 \fB\fB-\(mistrict\fR\fR
109 Directs the utility to append the suffix \fB\&.mo\fR to the generating message
110 object file name if it doesn't have this suffix. This option is ignored if
111 Solaris message catalogs are processed.
121 \fB\fB-\(miverbose\fR\fR
124 Verbose. Lists duplicate message identifiers if Solaris message catalog files
125 are processed. Message strings are not redefined.
127 If GNU-compatible message files are processed, this option detects and
128 diagnoses input file anomalies which might represent translation errors. The
129 msgid and msgstr strings are studied and compared. It is considered abnormal if
130 one string starts or ends with a newline while the other does not. Also, if the
131 string represents a format string used in a printf-like function, both strings
132 should have the same number of % format specifiers, with matching types. If the
133 flag \fBc-format\fR appears in the special comment '\fB#\fR' for this entry, a
140 The format of portable object files (\fB\&.po\fR files) is defined as follows.
141 Each \fB\&.po\fR file contains one or more lines, with each line containing
142 either a comment or a statement. Comments start the line with a pound sign
143 (\fB#\fR) and end with the newline character. All comments (except special
144 comments described later) and empty lines are ignored. The format of a
149 \fIdirective\fR \fIvalue\fR
156 Each \fIdirective\fR starts at the beginning of the line and is separated from
157 \fIvalue\fR by white space (such as one or more space or tab characters).
158 \fIvalue\fR consists of one or more quoted strings separated by white space.
159 Use any of the following types of directives for the Solaris message file:
163 domain \fIdomainname\fR
164 msgid \fImessage_identifier\fR
165 msgstr \fImessage_string\fR
172 For a GNU-compatible message file, use any of the following types of
177 domain \fIdomainname\fR
178 msgid \fImessage_identifier\fR
179 msgid_plural \fIuntranslated_string_plural\fR
180 msgstr \fImessage_string\fR
181 msgstr[\fIn\fR] \fImessage_string\fR
188 The behavior of the \fBdomain\fR directive is affected by the options used. See
189 OPTIONS for the behavior when the \fB-o\fR or \fB-\(mioutput-file\fR options
190 are specified. If the \fB-o\fR or \fB-\(mioutput-file\fR options are not
191 specified, the behavior of the \fBdomain\fR directive is as follows:
196 All msgids from the beginning of each \fB\&.po\fR file to the first
197 \fBdomain\fR directive are put into a default message object file. The default
198 message object file is named \fBmessages.mo\fR, if the Solaris message catalog
199 file format is used to generate the message object file or if the
200 \fB-\(mistrict\fR option is specified. Otherwise, the default message object
201 file is named \fBmessages\fR.
207 When \fBmsgfmt\fR encounters a \fBdomain\fR \fIdomainname\fR directive in the
208 \fB\&.po\fR file, all following msgids until the next \fBdomain\fR directive
209 are put into the message object file, named \fBdomainname.mo\fR, if the Solaris
210 message catalog file format is used to generate the message object file or if
211 the \fB-\(mistrict\fR option is specified. Otherwise, the msgids are put into
212 the message object file named \fBdomainname\fR.
218 Duplicate msgids are defined in the scope of each domain. That is, a msgid is
219 considered a duplicate only if the identical msgid exists in the same domain.
225 All duplicate msgids are ignored.
229 The \fBmsgid\fR directive specifies the value of a message identifier
230 associated with the directive that follows it. The \fBmsgid_plural\fR directive
231 specifies the plural form message specified to the plural message handling
232 functions \fBngettext()\fR, \fBdngettext()\fR, or \fBdcngettext()\fR. The
233 \fImessage_identifier\fR string identifies a target string to be used at
234 retrieval time. Each statement containing a \fBmsgid\fR directive must be
235 followed by a statement containing a \fBmsgstr\fR directive or
236 \fBmsgstr\fR[\fIn\fR] directives.
239 The \fBmsgstr\fR directive specifies the target string associated with the
240 \fImessage_identifier\fR string declared in the immediately preceding
241 \fBmsgid\fR directive.
244 The directive \fBmsgstr\fR[\fIn\fR] (where \fIn\fR = 0, 1, 2, ...) specifies
245 the target string to be used with plural form handling functions
246 \fBngettext()\fR, \fBdngettext()\fR, and \fBdcngetttext()\fR.
249 Message strings can contain the escape sequences \fB\\n\fR for newline,
250 \fB\\t\fR for tab, \fB\\v\fR for vertical tab, \fB\\b\fR for backspace,
251 \fB\\r\fR for carriage return, \fB\\f\fR for formfeed, \fB\\\fR for backslash,
252 \fB\\"\fR for double quote, \fB\\a\fR for alarm, \fB\\ddd\fR for octal bit
253 pattern, and \fB\\xDD\fR for hexadecimal bit pattern.
256 Comments for a GNU-compatible message file should be in one of the following
257 formats (the \fBmsgfmt\fR utility will ignore these comments when processing
258 Solaris message files):
262 # \fItranslator-comments\fR
263 #. \fIautomatic-comments\fR
272 The '\fB#:\fR' comments indicate the location of the msgid string in the source
273 files in \fIfilename\fR:\fIline\fR format. The '\fB#\fR', '\fB#.\fR',
274 and '\fB#:\fR' comments are informative only and are silently ignored by the
275 \fBmsgfmt\fR utility. The '\fB#,\fR' comments require one or more flags
276 separated by the comma character. The following \fIflag\fRs can be specified:
283 This flag can be inserted by the translator. It shows that the \fBmsgstr\fR
284 string might not be a correct translation (anymore). Only the translator can
285 judge if the translation requires further modification or is acceptable as is.
286 Once satisfied with the translation, the translator removes this \fBfuzzy\fR
287 flag. If this flag is specified, the \fBmsgfmt\fR utility will not generate the
288 entry for the immediately following msgid in the output message catalog.
298 \fB\fBno-c-format\fR\fR
301 The \fBc-format\fR flag indicates that the \fBmsgid\fR string is used as a
302 format string by printf-like functions. In case the \fBc-format\fR flag is
303 given for a string, the \fBmsgfmt\fR utility does some more tests to check the
304 validity of the translation.
309 In the GNU-compatible message file, the \fBmsgid\fR entry with empty string
310 ("") is called the header entry and treated specially. If the message string
311 for the header entry contains \fBnplurals\fR=\fIvalue\fR, the value indicates
312 the number of plural forms. For example, if \fBnplurals\fR=4, there are four
313 plural forms. If \fBnplurals\fR is defined, the same line should contain
314 \fBplural=\fR\fIexpression\fR, separated by a semicolon character. The
315 \fIexpression\fR is a C language expression to determine which version of
316 \fBmsgstr\fR[\fIn\fR] is to be used based on the value of \fIn\fR, the last
317 argument of \fBngettext()\fR, \fBdngettext()\fR, or \fBdcngettext()\fR. For
322 nplurals=2; plural= n == 1 ? 0 : 1
329 indicates that there are two plural forms in the language. msgstr[0] is used if
330 n == 1, otherwise msgstr[1] is used. For another example:
334 nplurals=3; plural= n == 1 ? 0 : n == 2 ? 1 : 2
341 indicates that there are three plural forms in the language. msgstr[0] is used
342 if n == 1, msgstr[1] is used if n == 2, otherwise msgstr[2] is used.
345 If the header entry contains a \fBcharset\fR=\fIcodeset\fR string, the
346 \fIcodeset\fR is used to indicate the codeset to be used to encode the message
347 strings. If the output string's codeset is different from the message string's
348 codeset, codeset conversion from the message string's codeset to the output
349 string's codeset will be performed upon the call of \fBgettext()\fR,
350 \fBdgettext()\fR, \fBdcgettext()\fR, \fBngettext()\fR, \fBdngettext()\fR, and
351 \fBdcngettext()\fR for the GNU-compatible message catalogs. The output string's
352 codeset is determined by the current locale's codeset (the return value of
353 \fBnl_langinfo(CODESET\fR)) by default, and can be changed by the call of
354 \fBbind_textdomain_codeset()\fR.
355 .SS "Message catalog file format"
358 The \fBmsgfmt\fR utility can generate the message object both in Solaris
359 message catalog file format and in GNU-compatible message catalog file format.
360 If the \fB-s\fR option is specified and the input file is a Solaris \fB\&.po\fR
361 file, the \fBmsgfmt\fR utility generates the message object in Solaris message
362 catalog file format. If the \fB-g\fR option is specified and the input file is
363 a GNU \fB\&.po\fR file, the \fBmsgfmt\fR utility generates the message object
364 in GNU-compatible message catalog file format. If neither the \fB-s\fR nor
365 \fB-g\fR option is specified, the \fBmsgfmt\fR utility determines the message
366 catalog file format as follows:
371 If the \fB\&.po\fR file contains a valid GNU header entry (having an empty
372 string for \fBmsgid\fR), the \fBmsgfmt\fR utility uses the GNU-compatible
373 message catalog file format.
379 Otherwise, the \fBmsgfmt\fR utility uses the Solaris message catalog file
384 If the \fBmsgfmt\fR utility determined that the Solaris message catalog file
385 format is used, as above, but found the \fB\&.po\fR file contains directives
386 that are specific to the GNU-compatible message catalog file format, such as
387 \fBmsgid_plural\fR and \fBmsgstr\fR[\fIn\fR], the \fBmsgfmt\fR utility handles
388 those directives as invalid specifications.
391 \fBExample 1 \fRCreating message objects from message files
394 In this example, \fBmodule1.po\fR and \fBmodule2.po\fR are portable message
400 example% \fBcat module1.po\fR
401 # default domain "messages.mo"
403 msgstr "msg 1 translation"
407 msgstr "help 2 translation"
409 domain "error_domain"
411 msgstr "error 3 translation"
412 example% \fBcat module2.po\fR
413 # default domain "messages.mo"
415 msgstr "mesg 4 translation"
417 domain "error_domain"
419 msgstr "error 5 translation"
421 domain "window_domain"
423 msgstr "window 6 translation"
430 The following command will produce the output files \fBmessages.mo\fR,
431 \fBhelp_domain.mo\fR, and \fBerror_domain.mo\fR in Solaris message catalog file
437 example% \fBmsgfmt module1.po\fR
444 The following command will produce the output files \fBmessages.mo\fR,
445 \fBhelp_domain.mo\fR, \fBerror_domain.mo\fR, and \fBwindow_domain.mo\fR in
446 Solaris message catalog file format:
451 example% \fBmsgfmt module1.po module2.po\fR
458 The following command will produce the output file \fBhello.mo\fR in Solaris
459 message catalog file format:
464 example% \fBmsgfmt -o hello.mo module1.po module2.po\fR
469 .SH ENVIRONMENT VARIABLES
472 See \fBenviron\fR(5) for descriptions of the following environmental variables
473 that affect the execution of \fBmsgfmt\fR: \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR,
478 See \fBattributes\fR(5) for descriptions of the following attributes:
486 ATTRIBUTE TYPE ATTRIBUTE VALUE
494 \fBxgettext\fR(1), \fBgettext\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5),
499 Installing message catalogs under the C locale is pointless, since they are
500 ignored for the sake of efficiency.