Next: , Previous: YCP, Up: List of Programming Languages


15.5.17 Tcl - Tk's scripting language

RPMs
tcl
File extension
tcl
String syntax
"abc"
gettext shorthand
[_ "abc"]
gettext/ngettext functions
::msgcat::mc
textdomain

bindtextdomain
—, use ::msgcat::mcload instead
setlocale
automatic, uses LANG, but ignores LC_MESSAGES and LC_ALL
Prerequisite
package require msgcat
proc _ {s} {return [::msgcat::mc $s]}
Use or emulate GNU gettext
—, uses a Tcl specific message catalog format
Extractor
xgettext -k_
Formatting with positions
format "%2\$d %1\$d"
Portability
fully portable
po-mode marking

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.