• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@c This file is part of the GNU gettext manual.
2@c Copyright (C) 1995-2020 Free Software Foundation, Inc.
3@c See the file gettext.texi for copying conditions.
4
5@node Tcl
6@subsection Tcl - Tk's scripting language
7@cindex Tcl
8@cindex Tk's scripting language
9
10@table @asis
11@item RPMs
12tcl
13
14@item Ubuntu packages
15tcl
16
17@item File extension
18@code{tcl}
19
20@item String syntax
21@code{"abc"}
22
23@item gettext shorthand
24@code{[_ "abc"]}
25
26@item gettext/ngettext functions
27@code{::msgcat::mc}
28
29@item textdomain
30---
31
32@item bindtextdomain
33---, use @code{::msgcat::mcload} instead
34
35@item setlocale
36automatic, uses LANG, but ignores LC_MESSAGES and LC_ALL
37
38@item Prerequisite
39@code{package require msgcat}
40@*@code{proc _ @{s@} @{return [::msgcat::mc $s]@}}
41
42@item Use or emulate GNU gettext
43---, uses a Tcl specific message catalog format
44
45@item Extractor
46@code{xgettext -k_}
47
48@item Formatting with positions
49@code{format "%2\$d %1\$d"}
50
51@item Portability
52fully portable
53
54@item po-mode marking
55---
56@end table
57
58Two examples are available in the @file{examples} directory:
59@code{hello-tcl}, @code{hello-tcl-tk}.
60
61Before marking strings as internationalizable, substitutions of variables
62into the string need to be converted to @code{format} applications.  For
63example, @code{"file $filename not found"} becomes
64@code{[format "file %s not found" $filename]}.
65Only after this is done, can the strings be marked and extracted.
66After marking, this example becomes
67@code{[format [_ "file %s not found"] $filename]} or
68@code{[msgcat::mc "file %s not found" $filename]}.  Note that the
69@code{msgcat::mc} function implicitly calls @code{format} when more than one
70argument is given.
71