Next: Perl, Previous: wxWidgets library, Up: Individual Programming Languages [Contents][Index]
tcl
tcl
tcl
"abc"
[_ "abc"]
::msgcat::mc
—
—, use ::msgcat::mcload
instead
automatic, uses LANG, but ignores LC_MESSAGES and LC_ALL
package require msgcat
proc _ {s} {return [::msgcat::mc $s]}
—, uses a Tcl specific message catalog format
xgettext -k_
format "%2\$d %1\$d"
fully portable
—
Two examples are available in the examples directory:
hello-tcl
, hello-tcl-tk
.
Before marking strings as internationalizable, substitutions of variables
into the string need to be converted to format
applications. For
example, "file $filename not found"
becomes
[format "file %s not found" $filename]
.
Only after this is done, can the strings be marked and extracted.
After marking, this example becomes
[format [_ "file %s not found"] $filename]
or
[msgcat::mc "file %s not found" $filename]
. Note that the
msgcat::mc
function implicitly calls format
when more than one
argument is given.