1 MSGFMT(1) User Commands MSGFMT(1)
2
3
4
5 NAME
6 msgfmt - create a message object from a message file
7
8 SYNOPSIS
9 msgfmt [-D dir | --directory=dir]
10 [-f | --use-fuzzy] [-g]
11 [-o output-file | --output-file=output-file]
12 [-s] [--strict] [-v] [--verbose] filename.po...
13
14
15 DESCRIPTION
16 The msgfmt utility creates message object files from portable object
17 files (filename.po), without changing the portable object files.
18
19
20 The .po file contains messages displayed to users by system commands or
21 by application programs. .po files can be edited. The messages in these
22 files can be rewritten in any language supported by the system.
23
24
25 The xgettext(1) command can be used to create .po files from script or
26 programs.
27
28
29 msgfmt interprets data as characters according to the current setting
30 of the LC_CTYPE locale category or according to the codeset specified
31 in the .po file.
32
33 OPTIONS
34 The following options are supported:
35
36 -D dir
37 --directory=dir
38 Adds dir to the list for input files search.
39
40
41 -f
42 --use-fuzzy
43 Uses fuzzy entries in output. If this option
44 is not specified, fuzzy entries are not
45 included into the output. These options are
46 ignored if Solaris message catalogs are
47 processed.
48
49
50 -g
51 Directs the utility to generate the GNU-
52 compatible message catalog file. This option
53 cannot be specified with the -s option.
54
55
56 -o output-file
57 --output=output-file
58 Specifies the output file name as output-
59 file. All domain directives and duplicate
60 msgids in the .po file are ignored.
61
62
63 -s
64 Directs the utility to generate the Solaris
65 message catalog file. This option cannot be
66 specified with the -g option.
67
68
69 --strict
70 Directs the utility to append the suffix .mo
71 to the generating message object file name
72 if it doesn't have this suffix. This option
73 is ignored if Solaris message catalogs are
74 processed.
75
76
77 -v
78 --verbose
79 Verbose. Lists duplicate message identifiers
80 if Solaris message catalog files are
81 processed. Message strings are not
82 redefined.
83
84 If GNU-compatible message files are
85 processed, this option detects and diagnoses
86 input file anomalies which might represent
87 translation errors. The msgid and msgstr
88 strings are studied and compared. It is
89 considered abnormal if one string starts or
90 ends with a newline while the other does
91 not. Also, if the string represents a format
92 string used in a printf-like function, both
93 strings should have the same number of %
94 format specifiers, with matching types. If
95 the flag c-format appears in the special
96 comment '#' for this entry, a check is
97 performed.
98
99
100 USAGE
101 The format of portable object files (.po files) is defined as follows.
102 Each .po file contains one or more lines, with each line containing
103 either a comment or a statement. Comments start the line with a pound
104 sign (#) and end with the newline character. All comments (except
105 special comments described later) and empty lines are ignored. The
106 format of a statement is:
107
108 directive value
109
110
111
112
113 Each directive starts at the beginning of the line and is separated
114 from value by white space (such as one or more space or tab
115 characters). value consists of one or more quoted strings separated by
116 white space. Use any of the following types of directives for the
117 Solaris message file:
118
119 domain domainname
120 msgid message_identifier
121 msgstr message_string
122
123
124
125
126 For a GNU-compatible message file, use any of the following types of
127 directives:
128
129 domain domainname
130 msgid message_identifier
131 msgid_plural untranslated_string_plural
132 msgstr message_string
133 msgstr[n] message_string
134
135
136
137
138 The behavior of the domain directive is affected by the options used.
139 See OPTIONS for the behavior when the -o or --output-file options are
140 specified. If the -o or --output-file options are not specified, the
141 behavior of the domain directive is as follows:
142
143 o All msgids from the beginning of each .po file to the first
144 domain directive are put into a default message object file.
145 The default message object file is named messages.mo, if the
146 Solaris message catalog file format is used to generate the
147 message object file or if the --strict option is specified.
148 Otherwise, the default message object file is named
149 messages.
150
151 o When msgfmt encounters a domain domainname directive in the
152 .po file, all following msgids until the next domain
153 directive are put into the message object file, named
154 domainname.mo, if the Solaris message catalog file format is
155 used to generate the message object file or if the --strict
156 option is specified. Otherwise, the msgids are put into the
157 message object file named domainname.
158
159 o Duplicate msgids are defined in the scope of each domain.
160 That is, a msgid is considered a duplicate only if the
161 identical msgid exists in the same domain.
162
163 o All duplicate msgids are ignored.
164
165
166 The msgid directive specifies the value of a message identifier
167 associated with the directive that follows it. The msgid_plural
168 directive specifies the plural form message specified to the plural
169 message handling functions ngettext(), dngettext(), or dcngettext().
170 The message_identifier string identifies a target string to be used at
171 retrieval time. Each statement containing a msgid directive must be
172 followed by a statement containing a msgstr directive or msgstr[n]
173 directives.
174
175
176 The msgstr directive specifies the target string associated with the
177 message_identifier string declared in the immediately preceding msgid
178 directive.
179
180
181 The directive msgstr[n] (where n = 0, 1, 2, ...) specifies the target
182 string to be used with plural form handling functions ngettext(),
183 dngettext(), and dcngettext().
184
185
186 Message strings can contain the escape sequences \n for newline, \t for
187 tab, \v for vertical tab, \b for backspace, \r for carriage return, \f
188 for formfeed, \ for backslash, \" for double quote, \a for alarm, \ddd
189 for octal bit pattern, and \xDD for hexadecimal bit pattern.
190
191
192 Comments for a GNU-compatible message file should be in one of the
193 following formats (the msgfmt utility will ignore these comments when
194 processing Solaris message files):
195
196 # translator-comments
197 #. automatic-comments
198 #: reference..
199 #, flag
200
201
202
203
204 The '#:' comments indicate the location of the msgid string in the
205 source files in filename:line format. The '#', '#.', and '#:' comments
206 are informative only and are silently ignored by the msgfmt utility.
207 The '#,' comments require one or more flags separated by the comma
208 character. The following flags can be specified:
209
210 fuzzy
211 This flag can be inserted by the translator. It shows
212 that the msgstr string might not be a correct
213 translation (anymore). Only the translator can judge if
214 the translation requires further modification or is
215 acceptable as is. Once satisfied with the translation,
216 the translator removes this fuzzy flag. If this flag is
217 specified, the msgfmt utility will not generate the
218 entry for the immediately following msgid in the output
219 message catalog.
220
221
222 c-format
223 no-c-format
224 The c-format flag indicates that the msgid string is
225 used as a format string by printf-like functions. In
226 case the c-format flag is given for a string, the msgfmt
227 utility does some more tests to check the validity of
228 the translation.
229
230
231
232 In the GNU-compatible message file, the msgid entry with empty string
233 ("") is called the header entry and treated specially. If the message
234 string for the header entry contains nplurals=value, the value
235 indicates the number of plural forms. For example, if nplurals=4, there
236 are four plural forms. If nplurals is defined, the same line should
237 contain plural=expression, separated by a semicolon character. The
238 expression is a C language expression to determine which version of
239 msgstr[n] is to be used based on the value of n, the last argument of
240 ngettext(), dngettext(), or dcngettext(). For example,
241
242 nplurals=2; plural= n == 1 ? 0 : 1
243
244
245
246
247 indicates that there are two plural forms in the language. msgstr[0] is
248 used if n == 1, otherwise msgstr[1] is used. For another example:
249
250 nplurals=3; plural= n == 1 ? 0 : n == 2 ? 1 : 2
251
252
253
254
255 indicates that there are three plural forms in the language. msgstr[0]
256 is used if n == 1, msgstr[1] is used if n == 2, otherwise msgstr[2] is
257 used.
258
259
260 If the header entry contains a charset=codeset string, the codeset is
261 used to indicate the codeset to be used to encode the message strings.
262 If the output string's codeset is different from the message string's
263 codeset, codeset conversion from the message string's codeset to the
264 output string's codeset will be performed upon the call of gettext(),
265 dgettext(), dcgettext(), ngettext(), dngettext(), and dcngettext() for
266 the GNU-compatible message catalogs. The output string's codeset is
267 determined by the current locale's codeset (the return value of
268 nl_langinfo(CODESET)) by default, and can be changed by the call of
269 bind_textdomain_codeset().
270
271 Message catalog file format
272 The msgfmt utility can generate the message object both in Solaris
273 message catalog file format and in GNU-compatible message catalog file
274 format. If the -s option is specified and the input file is a Solaris
275 .po file, the msgfmt utility generates the message object in Solaris
276 message catalog file format. If the -g option is specified and the
277 input file is a GNU .po file, the msgfmt utility generates the message
278 object in GNU-compatible message catalog file format. If neither the -s
279 nor -g option is specified, the msgfmt utility determines the message
280 catalog file format as follows:
281
282 o If the .po file contains a valid GNU header entry (having an
283 empty string for msgid), the msgfmt utility uses the GNU-
284 compatible message catalog file format.
285
286 o Otherwise, the msgfmt utility uses the Solaris message
287 catalog file format.
288
289
290 If the msgfmt utility determined that the Solaris message catalog file
291 format is used, as above, but found the .po file contains directives
292 that are specific to the GNU-compatible message catalog file format,
293 such as msgid_plural and msgstr[n], the msgfmt utility handles those
294 directives as invalid specifications.
295
296 EXAMPLES
297 Example 1 Creating message objects from message files
298
299
300 In this example, module1.po and module2.po are portable message objects
301 files.
302
303
304 example% cat module1.po
305 # default domain "messages.mo"
306 msgid "msg 1"
307 msgstr "msg 1 translation"
308 #
309 domain "help_domain"
310 msgid "help 2"
311 msgstr "help 2 translation"
312 #
313 domain "error_domain"
314 msgid "error 3"
315 msgstr "error 3 translation"
316 example% cat module2.po
317 # default domain "messages.mo"
318 msgid "mesg 4"
319 msgstr "mesg 4 translation"
320 #
321 domain "error_domain"
322 msgid "error 5"
323 msgstr "error 5 translation"
324 #
325 domain "window_domain"
326 msgid "window 6"
327 msgstr "window 6 translation"
328
329
330
331
332 The following command will produce the output files messages.mo,
333 help_domain.mo, and error_domain.mo in Solaris message catalog file
334 format:
335
336
337 example% msgfmt module1.po
338
339
340
341
342 The following command will produce the output files messages.mo,
343 help_domain.mo, error_domain.mo, and window_domain.mo in Solaris
344 message catalog file format:
345
346
347 example% msgfmt module1.po module2.po
348
349
350
351
352 The following command will produce the output file hello.mo in Solaris
353 message catalog file format:
354
355
356 example% msgfmt -o hello.mo module1.po module2.po
357
358
359
360 ENVIRONMENT VARIABLES
361 See environ(5) for descriptions of the following environmental
362 variables that affect the execution of msgfmt: LC_CTYPE, LC_MESSAGES,
363 and NLSPATH.
364
365 ATTRIBUTES
366 See attributes(5) for descriptions of the following attributes:
367
368
369
370
371 +---------------+-----------------+
372 |ATTRIBUTE TYPE | ATTRIBUTE VALUE |
373 +---------------+-----------------+
374 |CSI | Enabled |
375 +---------------+-----------------+
376
377 SEE ALSO
378 xgettext(1), gettext(3C), setlocale(3C), attributes(5), environ(5)
379
380 NOTES
381 Installing message catalogs under the C locale is pointless, since they
382 are ignored for the sake of efficiency.
383
384
385
386 September 17, 2001 MSGFMT(1)