1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
'\" te
.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
.\" 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.
.\" 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.
.\" 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]
.TH MSGFMT 1 "Sep 17, 2001"
.SH NAME
msgfmt \- create a message object from a message file
.SH SYNOPSIS
.LP
.nf
\fBmsgfmt\fR [\fB-D\fR \fIdir\fR | \fB-\(midirectory\fR=\fIdir\fR]
[\fB-f\fR | \fB-\(miuse-fuzzy\fR] [\fB-g\fR]
[\fB-o\fR \fIoutput-file\fR | \fB-\(mioutput-file\fR=\fIoutput-file\fR]
[\fB-s\fR] [\fB-\(mistrict\fR] [\fB-v\fR] [\fB-\(miverbose\fR] \fIfilename\fR.po...
.fi
.SH DESCRIPTION
.sp
.LP
The \fBmsgfmt\fR utility creates message object files from portable object
files (\fIfilename\fR\fB\&.po\fR), without changing the portable object files.
.sp
.LP
The \fB\&.po\fR file contains messages displayed to users by system commands or
by application programs. \fB\&.po\fR files can be edited. The messages in these
files can be rewritten in any language supported by the system.
.sp
.LP
The \fBxgettext\fR(1) command can be used to create \fB\&.po\fR files from
script or programs.
.sp
.LP
\fBmsgfmt\fR interprets data as characters according to the current setting of
the \fBLC_CTYPE\fR locale category or according to the codeset specified in the
\fB\&.po\fR file.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-D\fR \fIdir\fR\fR
.ad
.br
.na
\fB\fB-\(midirectory=\fR\fIdir\fR\fR
.ad
.RS 27n
Adds \fIdir\fR to the list for input files search.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR\fR
.ad
.br
.na
\fB\fB-\(miuse-fuzzy\fR\fR
.ad
.RS 27n
Uses fuzzy entries in output. If this option is not specified, fuzzy entries
are not included into the output. These options are ignored if Solaris message
catalogs are processed.
.RE
.sp
.ne 2
.na
\fB\fB-g\fR\fR
.ad
.RS 27n
Directs the utility to generate the GNU-compatible message catalog file. This
option cannot be specified with the \fB-s\fR option.
.RE
.sp
.ne 2
.na
\fB\fB-o\fR \fIoutput-file\fR\fR
.ad
.br
.na
\fB\fB-\(mioutput=\fR\fIoutput-file\fR\fR
.ad
.RS 27n
Specifies the output file name as \fIoutput-file\fR. All domain directives and
duplicate msgids in the .\fBpo\fR file are ignored.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 27n
Directs the utility to generate the Solaris message catalog file. This option
cannot be specified with the \fB-g\fR option.
.RE
.sp
.ne 2
.na
\fB\fB-\(mistrict\fR\fR
.ad
.RS 27n
Directs the utility to append the suffix \fB\&.mo\fR to the generating message
object file name if it doesn't have this suffix. This option is ignored if
Solaris message catalogs are processed.
.RE
.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.br
.na
\fB\fB-\(miverbose\fR\fR
.ad
.RS 27n
Verbose. Lists duplicate message identifiers if Solaris message catalog files
are processed. Message strings are not redefined.
.sp
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 and compared. It is considered abnormal if
one string starts or ends with a newline while the other does not. Also, if the
string represents a format string used in a printf-like function, both strings
should have the same number of % format specifiers, with matching types. If the
flag \fBc-format\fR appears in the special comment '\fB#\fR' for this entry, a
check is performed.
.RE
.SH USAGE
.sp
.LP
The format of portable object files (\fB\&.po\fR files) is defined as follows.
Each \fB\&.po\fR file contains one or more lines, with each line containing
either a comment or a statement. Comments start the line with a pound sign
(\fB#\fR) and end with the newline character. All comments (except special
comments described later) and empty lines are ignored. The format of a
statement is:
.sp
.in +2
.nf
\fIdirective\fR \fIvalue\fR
.fi
.in -2
.sp
.sp
.LP
Each \fIdirective\fR starts at the beginning of the line and is separated from
\fIvalue\fR by white space (such as one or more space or tab characters).
\fIvalue\fR consists of one or more quoted strings separated by white space.
Use any of the following types of directives for the Solaris message file:
.sp
.in +2
.nf
domain \fIdomainname\fR
msgid \fImessage_identifier\fR
msgstr \fImessage_string\fR
.fi
.in -2
.sp
.sp
.LP
For a GNU-compatible message file, use any of the following types of
directives:
.sp
.in +2
.nf
domain \fIdomainname\fR
msgid \fImessage_identifier\fR
msgid_plural \fIuntranslated_string_plural\fR
msgstr \fImessage_string\fR
msgstr[\fIn\fR] \fImessage_string\fR
.fi
.in -2
.sp
.sp
.LP
The behavior of the \fBdomain\fR directive is affected by the options used. See
OPTIONS for the behavior when the \fB-o\fR or \fB-\(mioutput-file\fR options
are specified. If the \fB-o\fR or \fB-\(mioutput-file\fR options are not
specified, the behavior of the \fBdomain\fR directive is as follows:
.RS +4
.TP
.ie t \(bu
.el o
All msgids from the beginning of each \fB\&.po\fR file to the first
\fBdomain\fR directive are put into a default message object file. The default
message object file is named \fBmessages.mo\fR, if the Solaris message catalog
file format is used to generate the message object file or if the
\fB-\(mistrict\fR option is specified. Otherwise, the default message object
file is named \fBmessages\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
When \fBmsgfmt\fR encounters a \fBdomain\fR \fIdomainname\fR directive in the
\fB\&.po\fR file, all following msgids until the next \fBdomain\fR directive
are put into the message object file, named \fBdomainname.mo\fR, if the Solaris
message catalog file format is used to generate the message object file or if
the \fB-\(mistrict\fR option is specified. Otherwise, the msgids are put into
the message object file named \fBdomainname\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el 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.
.RE
.RS +4
.TP
.ie t \(bu
.el o
All duplicate msgids are ignored.
.RE
.sp
.LP
The \fBmsgid\fR directive specifies the value of a message identifier
associated with the directive that follows it. The \fBmsgid_plural\fR directive
specifies the plural form message specified to the plural message handling
functions \fBngettext()\fR, \fBdngettext()\fR, or \fBdcngettext()\fR. The
\fImessage_identifier\fR string identifies a target string to be used at
retrieval time. Each statement containing a \fBmsgid\fR directive must be
followed by a statement containing a \fBmsgstr\fR directive or
\fBmsgstr\fR[\fIn\fR] directives.
.sp
.LP
The \fBmsgstr\fR directive specifies the target string associated with the
\fImessage_identifier\fR string declared in the immediately preceding
\fBmsgid\fR directive.
.sp
.LP
The directive \fBmsgstr\fR[\fIn\fR] (where \fIn\fR = 0, 1, 2, ...) specifies
the target string to be used with plural form handling functions
\fBngettext()\fR, \fBdngettext()\fR, and \fBdcngetttext()\fR.
.sp
.LP
Message strings can contain the escape sequences \fB\\n\fR for newline,
\fB\\t\fR for tab, \fB\\v\fR for vertical tab, \fB\\b\fR for backspace,
\fB\\r\fR for carriage return, \fB\\f\fR for formfeed, \fB\\\fR for backslash,
\fB\\"\fR for double quote, \fB\\a\fR for alarm, \fB\\ddd\fR for octal bit
pattern, and \fB\\xDD\fR for hexadecimal bit pattern.
.sp
.LP
Comments for a GNU-compatible message file should be in one of the following
formats (the \fBmsgfmt\fR utility will ignore these comments when processing
Solaris message files):
.sp
.in +2
.nf
# \fItranslator-comments\fR
#. \fIautomatic-comments\fR
#: \fIreference\fR..
#, \fIflag\fR
.fi
.in -2
.sp
.sp
.LP
The '\fB#:\fR' comments indicate the location of the msgid string in the source
files in \fIfilename\fR:\fIline\fR format. The '\fB#\fR', '\fB#.\fR',
and '\fB#:\fR' comments are informative only and are silently ignored by the
\fBmsgfmt\fR utility. The '\fB#,\fR' comments require one or more flags
separated by the comma character. The following \fIflag\fRs can be specified:
.sp
.ne 2
.na
\fB\fBfuzzy\fR\fR
.ad
.RS 15n
This flag can be inserted by the translator. It shows that the \fBmsgstr\fR
string might not be a correct translation (anymore). Only the translator can
judge if the translation requires further modification or is acceptable as is.
Once satisfied with the translation, the translator removes this \fBfuzzy\fR
flag. If this flag is specified, the \fBmsgfmt\fR utility will not generate the
entry for the immediately following msgid in the output message catalog.
.RE
.sp
.ne 2
.na
\fB\fBc-format\fR\fR
.ad
.br
.na
\fB\fBno-c-format\fR\fR
.ad
.RS 15n
The \fBc-format\fR flag indicates that the \fBmsgid\fR string is used as a
format string by printf-like functions. In case the \fBc-format\fR flag is
given for a string, the \fBmsgfmt\fR utility does some more tests to check the
validity of the translation.
.RE
.sp
.LP
In the GNU-compatible message file, the \fBmsgid\fR entry with empty string
("") is called the header entry and treated specially. If the message string
for the header entry contains \fBnplurals\fR=\fIvalue\fR, the value indicates
the number of plural forms. For example, if \fBnplurals\fR=4, there are four
plural forms. If \fBnplurals\fR is defined, the same line should contain
\fBplural=\fR\fIexpression\fR, separated by a semicolon character. The
\fIexpression\fR is a C language expression to determine which version of
\fBmsgstr\fR[\fIn\fR] is to be used based on the value of \fIn\fR, the last
argument of \fBngettext()\fR, \fBdngettext()\fR, or \fBdcngettext()\fR. For
example,
.sp
.in +2
.nf
nplurals=2; plural= n == 1 ? 0 : 1
.fi
.in -2
.sp
.sp
.LP
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:
.sp
.in +2
.nf
nplurals=3; plural= n == 1 ? 0 : n == 2 ? 1 : 2
.fi
.in -2
.sp
.sp
.LP
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.
.sp
.LP
If the header entry contains a \fBcharset\fR=\fIcodeset\fR string, the
\fIcodeset\fR is used to indicate the codeset to be used to encode the message
strings. If the output string's codeset is different from the message string's
codeset, codeset conversion from the message string's codeset to the output
string's codeset will be performed upon the call of \fBgettext()\fR,
\fBdgettext()\fR, \fBdcgettext()\fR, \fBngettext()\fR, \fBdngettext()\fR, and
\fBdcngettext()\fR for the GNU-compatible message catalogs. The output string's
codeset is determined by the current locale's codeset (the return value of
\fBnl_langinfo(CODESET\fR)) by default, and can be changed by the call of
\fBbind_textdomain_codeset()\fR.
.SS "Message catalog file format"
.sp
.LP
The \fBmsgfmt\fR utility can generate the message object both in Solaris
message catalog file format and in GNU-compatible message catalog file format.
If the \fB-s\fR option is specified and the input file is a Solaris \fB\&.po\fR
file, the \fBmsgfmt\fR utility generates the message object in Solaris message
catalog file format. If the \fB-g\fR option is specified and the input file is
a GNU \fB\&.po\fR file, the \fBmsgfmt\fR utility generates the message object
in GNU-compatible message catalog file format. If neither the \fB-s\fR nor
\fB-g\fR option is specified, the \fBmsgfmt\fR utility determines the message
catalog file format as follows:
.RS +4
.TP
.ie t \(bu
.el o
If the \fB\&.po\fR file contains a valid GNU header entry (having an empty
string for \fBmsgid\fR), the \fBmsgfmt\fR utility uses the GNU-compatible
message catalog file format.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Otherwise, the \fBmsgfmt\fR utility uses the Solaris message catalog file
format.
.RE
.sp
.LP
If the \fBmsgfmt\fR utility determined that the Solaris message catalog file
format is used, as above, but found the \fB\&.po\fR file contains directives
that are specific to the GNU-compatible message catalog file format, such as
\fBmsgid_plural\fR and \fBmsgstr\fR[\fIn\fR], the \fBmsgfmt\fR utility handles
those directives as invalid specifications.
.SH EXAMPLES
.LP
\fBExample 1 \fRCreating message objects from message files
.sp
.LP
In this example, \fBmodule1.po\fR and \fBmodule2.po\fR are portable message
objects files.
.sp
.in +2
.nf
example% \fBcat module1.po\fR
# 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% \fBcat module2.po\fR
# 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"
.fi
.in -2
.sp
.sp
.LP
The following command will produce the output files \fBmessages.mo\fR,
\fBhelp_domain.mo\fR, and \fBerror_domain.mo\fR in Solaris message catalog file
format:
.sp
.in +2
.nf
example% \fBmsgfmt module1.po\fR
.fi
.in -2
.sp
.sp
.LP
The following command will produce the output files \fBmessages.mo\fR,
\fBhelp_domain.mo\fR, \fBerror_domain.mo\fR, and \fBwindow_domain.mo\fR in
Solaris message catalog file format:
.sp
.in +2
.nf
example% \fBmsgfmt module1.po module2.po\fR
.fi
.in -2
.sp
.sp
.LP
The following command will produce the output file \fBhello.mo\fR in Solaris
message catalog file format:
.sp
.in +2
.nf
example% \fBmsgfmt -o hello.mo module1.po module2.po\fR
.fi
.in -2
.sp
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environmental variables
that affect the execution of \fBmsgfmt\fR: \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR,
and \fBNLSPATH\fR.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
CSI Enabled
.TE
.SH SEE ALSO
.sp
.LP
\fBxgettext\fR(1), \fBgettext\fR(3C), \fBsetlocale\fR(3C), \fBattributes\fR(5),
\fBenviron\fR(5)
.SH NOTES
.sp
.LP
Installing message catalogs under the C locale is pointless, since they are
ignored for the sake of efficiency.
|