annotate src/intl.c @ 563:183866b06e0b

[xemacs-hg @ 2001-05-24 07:50:48 by ben] Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c: -- defsymbol -> DEFSYMBOL. -- add an error type to all errors. -- eliminate the error functions in eval.c that let you just use Qerror as the type. -- redo the error API to be more consistent, sensibly named, and easier to use. -- redo the error hierarchy somewhat. create new errors: structure-formation-error, gui-error, invalid-constant, stack-overflow, out-of-memory, process-error, network-error, sound-error, printing-unreadable-object, base64-conversion- error; coding-system-error renamed to text-conversion error; some others. -- fix Mule problems in error strings in emodules.c, tooltalk.c. -- fix error handling in mswin open-network-stream. -- Mule-ize all sound files and clean up the headers. -- nativesound.h -> sound.h and used for all sound files. -- move some shared stuff into glyphs-shared.c: first attempt at eliminating some of the massive GTK code duplication. xemacs.mak: add glyphs-shared.c. xemacs-faq.texi: document how to debug X errors subr.el: fix doc string to reflect reality
author ben
date Thu, 24 May 2001 07:51:33 +0000
parents 576fb035e263
children 943eaba38521
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Various functions for internationalizing XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* This stuff is far, far from working. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "bytecode.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #if defined (HAVE_X_WINDOWS) && defined (HAVE_X11_XLOCALE_H)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include <X11/Xlocale.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #ifdef HAVE_LOCALE_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include <locale.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #ifdef I18N4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include <X11/Xlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 unsigned long input_method_event_mask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 Atom wc_atom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 /* init_input -- Set things up for i18n level 4 input.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
48 init_input (const char *res_name, const char *res_class, Display *display)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 XIMStyles *styles;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 unsigned short i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 input_method = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 input_method_style = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 initial_input_context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 input_method_event_mask = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 input_method = XOpenIM (display, NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (char *) res_name, (char *) res_class);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 if (!input_method)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 stderr_out ("WARNING: XOpenIM() failed...no input server\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 /* Query input method for supported input styles and pick one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 Right now, we choose a style which supports root-window preediting. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 XGetIMValues (input_method, XNQueryInputStyle, &styles, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 for (i = 0; i < styles->count_styles; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 if (styles->supported_styles[i] == (XIMPreeditNothing|XIMStatusNothing))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 input_method_style= styles->supported_styles[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 if (!input_method_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 stderr_out ("WARNING: Could not find suitable input style.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 initial_input_context = XCreateIC (input_method,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 XNInputStyle, input_method_style,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 if (!initial_input_context)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 stderr_out ("WARNING: Could not create input context.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 XGetICValues (initial_input_context,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 XNFilterEvents, &input_method_event_mask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 /* Get a new atom for wide character client messages. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 wc_atom = XInternAtom (display, "Wide Character Event", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 /*static widechar_string composed_input_buf = EMPTY_WIDECHAR_STRING;*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #define XIM_Composed_Text_BUFSIZE 64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 typedef struct XIM_Composed_Text {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 wchar_t data [XIM_Composed_Text_BUFSIZE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 } XIM_Composed_Text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 static XIM_Composed_Text composed_input_buf = {XIM_Composed_Text_BUFSIZE, {0}};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 /*static wcidechar composed_input_buf [64] = {0};*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 Window main_window; /* Convenient way to refer to main Era window. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 /* x_get_composed_input -- Process results of input method composition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 This function copies the results of the input method composition to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 composed_input_buf. Then for each character, a custom event of type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 wc_atom is sent with the character as its data.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 It is probably more efficient to copy the composition results to some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 allocated memory and send a single event pointing to that memory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 That would cut down on the event processing as well as allow quick
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 insertion into the buffer of the whole string. It might require some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 care, though, to avoid fragmenting memory through the allocation and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 freeing of many small chunks. Maybe the existing system for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (single-byte) string allocation can be used, multiplying the length by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 sizeof (wchar_t) to get the right size.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 x_get_composed_input (XKeyPressedEvent *x_key_event, XIC context,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 Display *display)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 KeySym keysym;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Status status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 XClientMessageEvent new_event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 retry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 len = XwcLookupString (context, x_key_event, composed_input_buf.data,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 composed_input_buf.size, &keysym, &status);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 switch (status)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 case XBufferOverflow:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 /* GROW_WC_STRING (&composed_input_buf, 32); mrb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 goto retry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 case XLookupChars:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 new_event.type = ClientMessage;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 new_event.display = x_key_event->display;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 new_event.window = x_key_event->window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 new_event.message_type = wc_atom;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 new_event.format = 32; /* 32-bit wide data */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 new_event.data.l[2] = new_event.data.l[3] = new_event.data.l[4] = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 new_event.data.l[0] = x_key_event->time;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 for (i = 0; i < len; i++) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 new_event.data.l[1] = ((wchar_t *) composed_input_buf.data)[i];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 XSendEvent (display, main_window, False, 0L, (XEvent *) &new_event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 #endif /* I18N4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 Lisp_Object Qdefer_gettext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 DEFUN ("ignore-defer-gettext", Fignore_defer_gettext, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
171 If OBJECT is of the form (defer-gettext "string"), return the string.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 The purpose of the defer-gettext symbol is to identify strings which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 are translated when they are referenced instead of when they are defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
175 (object))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
177 if (CONSP (object)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
178 && SYMBOLP (Fcar (object))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
179 && EQ (Fcar (object), Qdefer_gettext))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
180 return Fcar (Fcdr (object));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 else
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
182 return object;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 DEFUN ("gettext", Fgettext, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 Look up STRING in the default message domain and return its translation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 This function does nothing if I18N3 was not enabled when Emacs was compiled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 /* #### What should happen here is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 1) If the string has no `string-translatable' property or its value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 is nil, no translation takes place. The `string-translatable' property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 only gets added when a constant string is read in from a .el or .elc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 file, to avoid excessive translation. (The user can also explicitly
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 add this property to a string.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 2) If the string's `string-translatable' property is a string,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 that string should be returned. `format' add this property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 This allows translation to take place at the proper time but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 avoids excessive translation if the string is not destined for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 a translating stream. (See print_internal().)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 3) If gettext() returns the same string, then Fgettext() should return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 the same object, minus the 'string-translatable' property. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 if (STRINGP (string)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 #ifdef DEBUG_XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 stderr_out ("\nFgettext (%s) called.\n", XSTRING_DATA (string));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 return build_string (gettext ((char *) XSTRING_DATA (string)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 return string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 return string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 /* #### add the function `force-gettext', perhaps in Lisp. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 ignores the `string-translatable' property and simply calls gettext()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 on the string. Add the functions `set-string-translatable' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 `set-stream-translating'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 DEFUN ("dgettext", Fdgettext, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 Look up STRING in the specified message domain and return its translation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 This function does nothing if I18N3 was not enabled when Emacs was compiled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (domain, string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 CHECK_STRING (domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 CHECK_STRING (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 return build_string (dgettext ((char *) XSTRING_DATA (domain),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 (char *) XSTRING_DATA (string)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 return string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 DEFUN ("bind-text-domain", Fbind_text_domain, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 Associate a pathname with a message domain.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 Here's how the path to message files is constructed under SunOS 5.0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 {pathname}/{LANG}/LC_MESSAGES/{domain}.mo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 This function does nothing if I18N3 was not enabled when Emacs was compiled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (domain, pathname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 CHECK_STRING (domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 CHECK_STRING (pathname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 return build_string (bindtextdomain ((char *) XSTRING_DATA (domain),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (char *) XSTRING_DATA (pathname)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 extern int load_in_progress;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 DEFUN ("set-domain", Fset_domain, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 Specify the domain used for translating messages in this source file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 The domain declaration may only appear at top-level, and should precede
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 all function and variable definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 The presence of this declaration in a compiled file effectively sets the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 domain of all functions and variables which are defined in that file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 Bug: it has no effect on source (.el) files, only compiled (.elc) files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (domain_name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 CHECK_STRING (domain_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 if (load_in_progress)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 return (domain_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 init_intl_very_early (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 #if defined (I18N2) || defined (I18N3) || defined (I18N4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 setlocale (LC_ALL, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 setlocale(LC_NUMERIC, "C");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 textdomain ("emacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 syms_of_intl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 /* defer-gettext is defined as a symbol because when it is used in menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 specification strings, it is not evaluated as a function by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 menu_item_descriptor_to_widget_value(). */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
307 DEFSYMBOL (Qdefer_gettext);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 DEFSUBR (Fignore_defer_gettext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 DEFSUBR (Fgettext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 DEFSUBR (Fdgettext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 DEFSUBR (Fbind_text_domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 DEFSUBR (Fset_domain);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 vars_of_intl (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 #ifdef I18N2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 Fprovide (intern ("i18n2"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 Fprovide (intern ("i18n3"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }