1
/* tcl_gettext - Module implementing gettext interface for Tcl.
2
Copyright (C) 1995, 1998 Free Software Foundation, Inc.
3
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, December 1995.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2, or (at your option)
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software Foundation,
17
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27
/* Data for Tcl interpreter interface. */
30
/* Prototypes for local functions. */
32
tcl_gettext (ClientData client_data, Tcl_Interp *interp, int argc,
35
tcl_textdomain (ClientData client_data, Tcl_Interp *interp, int argc,
38
tcl_bindtextdomain (ClientData client_data, Tcl_Interp *interp, int argc,
42
/* Initialization functions. Called from the tclAppInit.c/tkAppInit.c
43
or while the dynamic loading with Tcl7.x, x>= 5. */
48
Tcl_CreateCommand (interp, "gettext", tcl_gettext, (ClientData) 0,
49
(Tcl_CmdDeleteProc *) NULL);
50
Tcl_CreateCommand (interp, "textdomain", tcl_textdomain, (ClientData) 0,
51
(Tcl_CmdDeleteProc *) NULL);
52
Tcl_CreateCommand (interp, "bindtextdomain", tcl_bindtextdomain,
53
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
60
tcl_gettext (client_data, interp, argc, argv)
61
ClientData client_data;
66
const char *domainname = NULL;
67
int category = LC_MESSAGES;
70
/* The pointer which is assigned in the following statement might
71
reference an invalid part of the address space. But we don't use
72
this value before we know the pointer is correct. */
79
if (strcmp (argv[3], "LC_CTYPE") == 0)
84
if (strcmp (argv[3], "LC_COLLATE") == 0)
85
category = LC_COLLATE;
89
if (strcmp (argv[3], "LC_MESSAGES") == 0)
90
category = LC_MESSAGES;
94
if (strcmp (argv[3], "LC_MONETARY") == 0)
95
category = LC_MONETARY;
99
if (strcmp (argv[3], "LC_NUMERIC") == 0)
100
category = LC_NUMERIC;
104
if (strcmp (argv[3], "LC_TIME") == 0)
109
interp->result = gettext ("invalid third argument");
115
domainname = argv[1];
120
interp->result = dcgettext (domainname, msgid, category);
124
interp->result = gettext ("wrong number of arguments");
133
tcl_textdomain (client_data, interp, argc, argv)
134
ClientData client_data;
141
interp->result = gettext ("wrong number of arguments");
145
interp->result = textdomain (argv[1]);
152
tcl_bindtextdomain (client_data, interp, argc, argv)
153
ClientData client_data;
160
interp->result = gettext ("wrong number of arguments");
164
return bindtextdomain (argv[1], argv[2]) == NULL ? TCL_ERROR : TCL_OK;