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