Mercurial > hg > xemacs-beta
annotate src/intl.c @ 5936:574f0cded429 cygwin
try to replace all nnnL or nnnUL constants with EMACS_[U]INT
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Sun, 13 Dec 2015 13:22:58 +0000 |
parents | 308d34e9f07d |
children |
rev | line source |
---|---|
771 | 1 /* Various functions for internationalizing XEmacs. |
428 | 2 Copyright (C) 1993, 1994, 1995 Board of Trustees, University of Illinois. |
826 | 3 Copyright (C) 2000, 2001, 2002 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4982
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
428 | 8 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4982
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4982
diff
changeset
|
10 option) any later version. |
428 | 11 |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4982
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 /* Synched up with: Not in FSF. */ | |
21 | |
22 #include <config.h> | |
23 #include "lisp.h" | |
24 | |
25 #if defined (HAVE_X_WINDOWS) && defined (HAVE_X11_XLOCALE_H) | |
26 #include <X11/Xlocale.h> | |
27 #else | |
28 #ifdef HAVE_LOCALE_H | |
29 #include <locale.h> | |
30 #endif | |
31 #endif | |
32 | |
771 | 33 #ifdef HAVE_X_WINDOWS |
34 int init_x_locale (Lisp_Object locale); | |
35 #endif | |
428 | 36 |
771 | 37 DEFUN ("current-locale", Fcurrent_locale, 0, 0, 0, /* |
38 Return the current locale. | |
39 This is of the form LANG_COUNTRY.ENCODING, or LANG_COUNTRY, or LANG, | |
40 or .ENCODING. Unfortunately, the meanings of these three values are | |
41 system-dependent, and there is no universal agreement. | |
42 */ | |
43 ()) | |
44 { | |
45 Extbyte *loc; | |
428 | 46 |
771 | 47 loc = setlocale (LC_CTYPE, NULL); |
48 if (!loc) | |
49 return Qnil; | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
3659
diff
changeset
|
50 return build_extstring (loc, Qctext); |
428 | 51 } |
52 | |
771 | 53 DEFUN ("set-current-locale", Fset_current_locale, 1, 1, 0, /* |
54 Set the user's current locale. | |
55 Takes a string, the value passed to setlocale(). | |
56 This is of the form LANG_COUNTRY.ENCODING, or LANG_COUNTRY, or LANG, | |
57 or .ENCODING. Unfortunately, the meanings of these three values are | |
58 system-dependent, and there is no universal agreement. This function | |
59 is meant to be called only from `set-language-environment', which | |
60 keeps tables to figure out the values to use for particular systems. | |
428 | 61 |
771 | 62 If the empty string is passed in, the locale is initialized from |
63 environment variables. | |
428 | 64 |
771 | 65 Returns nil if the call failed (typically, an invalid locale was given). |
66 Otherwise, returns the locale, or possibly a more-specified version. | |
428 | 67 */ |
771 | 68 (locale)) |
428 | 69 { |
771 | 70 Extbyte *loc; |
2946 | 71 Lisp_Object str; |
428 | 72 |
771 | 73 CHECK_STRING (locale); |
74 /* RedHat 6.2 contains a locale called "Francais" with the C-cedilla | |
75 encoded in ISO2022! */ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
76 loc = LISP_STRING_TO_EXTERNAL (locale, Qctext); |
771 | 77 loc = setlocale (LC_ALL, loc); |
78 if (!loc) | |
79 return Qnil; | |
2946 | 80 loc = xstrdup (loc); |
81 setlocale (LC_NUMERIC, "C"); | |
771 | 82 #ifdef HAVE_X_WINDOWS |
83 if (!init_x_locale (locale)) | |
428 | 84 { |
771 | 85 /* Locale not supported under X. Put it back. */ |
86 setlocale (LC_ALL, loc); | |
87 setlocale (LC_NUMERIC, "C"); | |
2946 | 88 free (loc); |
771 | 89 return Qnil; |
428 | 90 } |
771 | 91 #endif |
428 | 92 |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
3659
diff
changeset
|
93 str = build_extstring (loc, Qctext); |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
94 xfree (loc); |
2946 | 95 return str; |
428 | 96 } |
771 | 97 |
98 #if 0 | |
428 | 99 |
771 | 100 /* #### some old code that I really want to nuke, but I'm not completely |
101 sure what it did, so I'll leave it until we get around to implementing | |
102 message-translation and decide whether the functionality that this | |
103 is trying to support makes any sense. --ben */ | |
428 | 104 |
105 Lisp_Object Qdefer_gettext; | |
106 | |
826 | 107 DEFUN ("ignore-defer-gettext", Fignore_defer_gettext, 1, 1, 0, /* |
444 | 108 If OBJECT is of the form (defer-gettext "string"), return the string. |
428 | 109 The purpose of the defer-gettext symbol is to identify strings which |
110 are translated when they are referenced instead of when they are defined. | |
111 */ | |
444 | 112 (object)) |
428 | 113 { |
444 | 114 if (CONSP (object) |
115 && SYMBOLP (Fcar (object)) | |
116 && EQ (Fcar (object), Qdefer_gettext)) | |
117 return Fcar (Fcdr (object)); | |
428 | 118 else |
444 | 119 return object; |
428 | 120 } |
121 | |
771 | 122 #endif /* 0 */ |
123 | |
428 | 124 DEFUN ("gettext", Fgettext, 1, 1, 0, /* |
125 Look up STRING in the default message domain and return its translation. | |
126 This function does nothing if I18N3 was not enabled when Emacs was compiled. | |
127 */ | |
128 (string)) | |
129 { | |
130 #ifdef I18N3 | |
131 /* #### What should happen here is: | |
132 | |
133 1) If the string has no `string-translatable' property or its value | |
134 is nil, no translation takes place. The `string-translatable' property | |
135 only gets added when a constant string is read in from a .el or .elc | |
136 file, to avoid excessive translation. (The user can also explicitly | |
137 add this property to a string.) | |
138 2) If the string's `string-translatable' property is a string, | |
139 that string should be returned. `format' add this property. | |
140 This allows translation to take place at the proper time but | |
141 avoids excessive translation if the string is not destined for | |
142 a translating stream. (See print_internal().) | |
143 3) If gettext() returns the same string, then Fgettext() should return | |
144 the same object, minus the 'string-translatable' property. */ | |
145 | |
146 #endif | |
147 return string; | |
148 } | |
149 | |
150 #ifdef I18N3 | |
151 | |
152 /* #### add the function `force-gettext', perhaps in Lisp. This | |
153 ignores the `string-translatable' property and simply calls gettext() | |
154 on the string. Add the functions `set-string-translatable' and | |
155 `set-stream-translating'. */ | |
156 | |
157 #endif | |
158 | |
159 | |
160 | |
161 /************************************************************************/ | |
162 /* initialization */ | |
163 /************************************************************************/ | |
164 | |
165 void | |
771 | 166 init_intl (void) |
428 | 167 { |
3659 | 168 /* This function cannot GC, because it explicitly prevents it. */ |
771 | 169 if (initialized) |
170 { | |
171 int count = begin_gc_forbidden (); | |
853 | 172 Lisp_Object args[2]; |
173 | |
771 | 174 specbind (Qinhibit_quit, Qt); |
853 | 175 args[0] = Qreally_early_error_handler; |
176 args[1] = intern ("init-locale-at-early-startup"); | |
177 Fcall_with_condition_handler (2, args); | |
178 | |
771 | 179 /* Should be calling this here, but problems with |
180 `data-directory' and locating the files. See comment in | |
181 mule-cmds.el:`init-mule-at-startup'. | |
428 | 182 |
853 | 183 args[1] = intern ("init-unicode-at-early-startup"); |
184 Fcall_with_condition_handler (2, args); | |
771 | 185 */ |
186 unbind_to (count); | |
187 } | |
428 | 188 } |
189 | |
190 void | |
191 syms_of_intl (void) | |
192 { | |
193 DEFSUBR (Fgettext); | |
771 | 194 DEFSUBR (Fset_current_locale); |
195 DEFSUBR (Fcurrent_locale); | |
428 | 196 } |
197 | |
198 void | |
199 vars_of_intl (void) | |
200 { | |
201 #ifdef I18N3 | |
202 Fprovide (intern ("i18n3")); | |
203 #endif | |
771 | 204 |
205 #ifdef MULE | |
206 Fprovide (intern ("mule")); | |
207 #endif /* MULE */ | |
428 | 208 } |