annotate src/intl.c @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 9ee227acff29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Various functions for internationalizing XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* This stuff is far, far from working. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "bytecode.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #if defined (HAVE_X_WINDOWS) && defined (HAVE_X11_XLOCALE_H)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include <X11/Xlocale.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #ifdef HAVE_LOCALE_H
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include <locale.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #ifdef I18N4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include <X11/Xlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 unsigned long input_method_event_mask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Atom wc_atom;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 /* init_input -- Set things up for i18n level 4 input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 init_input (CONST char *res_name, CONST char *res_class, Display *display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 XIMStyles *styles;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 unsigned short i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 input_method = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 input_method_style = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 initial_input_context = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 input_method_event_mask = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 input_method = XOpenIM (display, NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (char *) res_name, (char *) res_class);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 if (!input_method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 stderr_out ("WARNING: XOpenIM() failed...no input server\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 /* Query input method for supported input styles and pick one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Right now, we choose a style which supports root-window preediting. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 XGetIMValues (input_method, XNQueryInputStyle, &styles, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 for (i = 0; i < styles->count_styles; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 if (styles->supported_styles[i] == (XIMPreeditNothing|XIMStatusNothing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 input_method_style= styles->supported_styles[i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 if (!input_method_style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 stderr_out ("WARNING: Could not find suitable input style.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 initial_input_context = XCreateIC (input_method,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 XNInputStyle, input_method_style,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 if (!initial_input_context)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 stderr_out ("WARNING: Could not create input context.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 XGetICValues (initial_input_context,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 XNFilterEvents, &input_method_event_mask,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 /* Get a new atom for wide character client messages. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 wc_atom = XInternAtom (display, "Wide Character Event", False);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 /*static widechar_string composed_input_buf = EMPTY_WIDECHAR_STRING;*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 #define XIM_Composed_Text_BUFSIZE 64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 typedef struct XIM_Composed_Text {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 int size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 wchar_t data [XIM_Composed_Text_BUFSIZE];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 } XIM_Composed_Text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 /*static wcidechar composed_input_buf [64] = {0};*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 Window main_window; /* Convenient way to refer to main Era window. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 /* x_get_composed_input -- Process results of input method composition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 This function copies the results of the input method composition to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 composed_input_buf. Then for each character, a custom event of type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 wc_atom is sent with the character as its data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 It is probably more efficient to copy the composition results to some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 allocated memory and send a single event pointing to that memory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 That would cut down on the event processing as well as allow quick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 insertion into the buffer of the whole string. It might require some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 care, though, to avoid fragmenting memory through the allocation and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 freeing of many small chunks. Maybe the existing system for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (single-byte) string allocation can be used, multipling the length by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 sizeof (wchar_t) to get the right size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 x_get_composed_input (XKeyPressedEvent *x_key_event, XIC context,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 Display *display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 KeySym keysym;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 Status status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 int len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 XClientMessageEvent new_event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 try_again:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 len = XwcLookupString (context, x_key_event, composed_input_buf.data,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 composed_input_buf.size, &keysym, &status);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 switch (status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 case XBufferOverflow:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 goto try_again;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 case XLookupChars:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 new_event.type = ClientMessage;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 new_event.display = x_key_event->display;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 new_event.window = x_key_event->window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 new_event.message_type = wc_atom;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 new_event.format = 32; /* 32-bit wide data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 new_event.data.l[0] = x_key_event->time;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 for (i = 0; i < len; i++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 #endif /* I18N4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 Lisp_Object Qdomain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 Lisp_Object Qdefer_gettext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 DEFUN ("ignore-defer-gettext", Fignore_defer_gettext, Signore_defer_gettext,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 If OBJ is of the form (defer-gettext \"string\"), return the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 The purpose of the defer-gettext symbol is to identify strings which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 are translated when they are referenced instead of when they are defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 Lisp_Object obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 if (CONSP (obj) && SYMBOLP (Fcar (obj)) && EQ (Fcar (obj), Qdefer_gettext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 return Fcar (Fcdr (obj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 return obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 DEFUN ("gettext", Fgettext, Sgettext, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Look up STRING in the default message domain and return its translation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 This function does nothing if I18N3 was not enabled when Emacs was compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 Lisp_Object string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 /* #### What should happen here is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 1) If the string has no `string-translatable' property or its value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 is nil, no translation takes place. The `string-translatable' property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 only gets added when a constant string is read in from a .el or .elc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 file, to avoid excessive translation. (The user can also explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 add this property to a string.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 2) If the string's `string-translatable' property is a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 that string should be returned. `format' add this property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 This allows translation to take place at the proper time but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 avoids excessive translation if the string is not destined for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 a translating stream. (See print_internal().)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 3) If gettext() returns the same string, then Fgettext() should return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 the same object, minus the 'string-translatable' property. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 if (STRINGP (string)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 #ifdef DEBUG_XEMACS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 stderr_out ("\nFgettext (%s) called.\n", string_data (XSTRING (string)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 return build_string (gettext ((char *) string_data (XSTRING (string))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 return string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 return string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 /* #### add the function `force-gettext', perhaps in Lisp. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ignores the `string-translatable' property and simply calls gettext()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 on the string. Add the functions `set-string-translatable' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 `set-stream-translating'. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 DEFUN ("dgettext", Fdgettext, Sdgettext, 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 Look up STRING in the specified message domain and return its translation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 This function does nothing if I18N3 was not enabled when Emacs was compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (domain, string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Lisp_Object domain, string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 CHECK_STRING (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 return build_string (dgettext ((char *) string_data (XSTRING (domain)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (char *) string_data (XSTRING (string))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 return string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 DEFUN ("bind-text-domain", Fbind_text_domain, Sbind_text_domain, 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 Associate a pathname with a message domain.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 Here's how the path to message files is constructed under SunOS 5.0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 {pathname}/{LANG}/LC_MESSAGES/{domain}.mo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 This function does nothing if I18N3 was not enabled when Emacs was compiled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (domain, pathname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Lisp_Object domain, pathname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 CHECK_STRING (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 CHECK_STRING (pathname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 return build_string (bindtextdomain ((char *) string_data (XSTRING (domain)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (char *) string_data (XSTRING (pathname))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 extern int load_in_progress;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 DEFUN ("set-domain", Fset_domain, Sset_domain, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Specify the domain used for translating messages in this source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 The domain declaration may only appear at top-level, and should preceed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 all function and variable definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 The presence of this declaration in a compiled file effectively sets the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 domain of all functions and variables which are defined in that file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 Bug: it has no effect on source (.el) files, only compiled (.elc) files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (domain_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Lisp_Object domain_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 CHECK_STRING (domain_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 if (load_in_progress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Vfile_domain = Fpurecopy (domain_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 return Vfile_domain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 return (domain_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 init_intl_very_early (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 #if defined (I18N2) || defined (I18N3) || defined (I18N4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 setlocale (LC_ALL, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 textdomain ("emacs");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 syms_of_intl (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 defsymbol (&Qdomain, "domain");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 /* defer-gettext is defined as a symbol because when it is used in menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 specification strings, it is not evaluated as a function by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 menu_item_descriptor_to_widget_value(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 defsymbol (&Qdefer_gettext, "defer-gettext");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 defsubr (&Signore_defer_gettext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 defsubr (&Sgettext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 defsubr (&Sdgettext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 defsubr (&Sbind_text_domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 defsubr (&Sset_domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 vars_of_intl (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 #ifdef I18N2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Fprovide (intern ("i18n2"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Fprovide (intern ("i18n3"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 }