208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
-
+
|
error.
.PP
For example, executing the code
.PP
.CS
\fB::msgcat::mcset\fR en hello "hello from ::"
namespace eval foo {
\fB::msgcat::mcset\fR en hello "hello from ::foo"
\fB::msgcat::mcset\fR en hello "hello from ::foo"
}
puts [\fB::msgcat::mc\fR hello]
namespace eval foo {puts [\fB::msgcat::mc\fR hello]}
.CE
.PP
will print
.PP
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
-
-
+
+
-
+
|
locale) the code
.PP
.CS
\fB::msgcat::mcset\fR en m1 ":: message1"
\fB::msgcat::mcset\fR en m2 ":: message2"
\fB::msgcat::mcset\fR en m3 ":: message3"
namespace eval ::foo {
\fB::msgcat::mcset\fR en m2 "::foo message2"
\fB::msgcat::mcset\fR en m3 "::foo message3"
\fB::msgcat::mcset\fR en m2 "::foo message2"
\fB::msgcat::mcset\fR en m3 "::foo message3"
}
namespace eval ::foo::bar {
\fB::msgcat::mcset\fR en m3 "::foo::bar message3"
\fB::msgcat::mcset\fR en m3 "::foo::bar message3"
}
namespace import \fB::msgcat::mc\fR
puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"
namespace eval ::foo {puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"}
namespace eval ::foo::bar {puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"}
.CE
.PP
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
-
+
|
\fBmcmset\fR, setting the necessary translation strings
for the language, likely enclosed in a \fBnamespace eval\fR
so that all source strings are tied to the namespace of
the package. For example, a short \fBes.msg\fR might contain:
.PP
.CS
namespace eval ::mypackage {
\fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!"
\fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!"
}
.CE
.SH "RECOMMENDED MESSAGE SETUP FOR PACKAGES"
.PP
If a package is installed into a subdirectory of the
\fBtcl_pkgPath\fR and loaded via \fBpackage require\fR, the
following procedure is recommended.
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
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
|
-
+
+
+
+
+
+
+
+
+
+
|
.PP
.CS
format "We produced %1\e$d units in location %2\e$s" $num $city
format "In location %2\e$s we produced %1\e$d units" $num $city
.CE
.PP
Similarly, positional parameters can be used with \fBscan\fR to
extract values from internationalized strings.
extract values from internationalized strings. Note that it is not
necessary to pass the output of \fB::msgcat::mc\fR to \fBformat\fR
directly; by passing the values to substitute in as arguments, the
formatting substitution is done directly.
.PP
.CS
\fBmsgcat::mc\fR {Produced %1$d at %2$s} $num $city
# ... where that key is mapped to one of the
# human-oriented versions by \fBmsgcat::mcset\fR
.CE
.SH CREDITS
.PP
The message catalog code was developed by Mark Harrison.
.SH "SEE ALSO"
format(n), scan(n), namespace(n), package(n)
.SH KEYWORDS
internationalization, i18n, localization, l10n, message, text, translation
.\" Local Variables:
.\" mode: nroff
.\" End:
|