Commit | Line | Data |
---|---|---|
9c9d63b1 PM |
1 | # locale-fr.m4 serial 20 |
2 | dnl Copyright (C) 2003, 2005-2021 Free Software Foundation, Inc. | |
8690e634 JK |
3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | |
5 | dnl with or without modifications, as long as this notice is preserved. | |
6 | ||
7 | dnl From Bruno Haible. | |
8 | ||
9 | dnl Determine the name of a french locale with traditional encoding. | |
10 | AC_DEFUN([gt_LOCALE_FR], | |
11 | [ | |
12 | AC_REQUIRE([AC_CANONICAL_HOST]) | |
13 | AC_REQUIRE([AM_LANGINFO_CODESET]) | |
14 | AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ | |
9c9d63b1 | 15 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
8690e634 JK |
16 | #include <locale.h> |
17 | #include <time.h> | |
18 | #if HAVE_LANGINFO_CODESET | |
19 | # include <langinfo.h> | |
20 | #endif | |
21 | #include <stdlib.h> | |
22 | #include <string.h> | |
23 | struct tm t; | |
24 | char buf[16]; | |
25 | int main () { | |
c0c3707f CB |
26 | /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl |
27 | imitates locale dependent behaviour by looking at the environment | |
28 | variables, and all locales use the UTF-8 encoding. */ | |
29 | #if defined __BEOS__ || defined __HAIKU__ | |
30 | return 1; | |
31 | #else | |
8690e634 | 32 | /* Check whether the given locale name is recognized by the system. */ |
c0c3707f | 33 | # if defined _WIN32 && !defined __CYGWIN__ |
8690e634 JK |
34 | /* On native Windows, setlocale(category, "") looks at the system settings, |
35 | not at the environment variables. Also, when an encoding suffix such | |
36 | as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE | |
37 | category of the locale to "C". */ | |
38 | if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL | |
39 | || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) | |
40 | return 1; | |
c0c3707f | 41 | # else |
8690e634 | 42 | if (setlocale (LC_ALL, "") == NULL) return 1; |
c0c3707f | 43 | # endif |
8690e634 JK |
44 | /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". |
45 | On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) | |
46 | is empty, and the behaviour of Tcl 8.4 in this locale is not useful. | |
47 | On OpenBSD 4.0, when an unsupported locale is specified, setlocale() | |
48 | succeeds but then nl_langinfo(CODESET) is "646". In this situation, | |
49 | some unit tests fail. | |
50 | On MirBSD 10, when an unsupported locale is specified, setlocale() | |
51 | succeeds but then nl_langinfo(CODESET) is "UTF-8". */ | |
c0c3707f | 52 | # if HAVE_LANGINFO_CODESET |
8690e634 JK |
53 | { |
54 | const char *cs = nl_langinfo (CODESET); | |
55 | if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 | |
56 | || strcmp (cs, "UTF-8") == 0) | |
57 | return 1; | |
58 | } | |
c0c3707f CB |
59 | # endif |
60 | # ifdef __CYGWIN__ | |
8690e634 JK |
61 | /* On Cygwin, avoid locale names without encoding suffix, because the |
62 | locale_charset() function relies on the encoding suffix. Note that | |
63 | LC_ALL is set on the command line. */ | |
64 | if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; | |
c0c3707f | 65 | # endif |
8690e634 JK |
66 | /* Check whether in the abbreviation of the second month, the second |
67 | character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only | |
68 | one byte long. This excludes the UTF-8 encoding. */ | |
69 | t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; | |
70 | if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; | |
c0c3707f | 71 | # if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ |
8690e634 JK |
72 | /* Check whether the decimal separator is a comma. |
73 | On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point | |
74 | are nl_langinfo(RADIXCHAR) are both ".". */ | |
75 | if (localeconv () ->decimal_point[0] != ',') return 1; | |
c0c3707f | 76 | # endif |
5e8754f9 | 77 | return 0; |
c0c3707f | 78 | #endif |
8690e634 | 79 | } |
9c9d63b1 | 80 | ]])]) |
8690e634 JK |
81 | if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then |
82 | case "$host_os" in | |
83 | # Handle native Windows specially, because there setlocale() interprets | |
84 | # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", | |
85 | # "fr" or "fra" as "French" or "French_France.1252", | |
86 | # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", | |
87 | # "ja" as "Japanese" or "Japanese_Japan.932", | |
88 | # and similar. | |
89 | mingw*) | |
90 | # Test for the native Windows locale name. | |
91 | if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
92 | gt_cv_locale_fr=French_France.1252 | |
93 | else | |
94 | # None found. | |
95 | gt_cv_locale_fr=none | |
96 | fi | |
97 | ;; | |
98 | *) | |
99 | # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because | |
100 | # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the | |
101 | # configure script would override the LC_ALL setting. Likewise for | |
102 | # LC_CTYPE, which is also set at the beginning of the configure script. | |
103 | # Test for the usual locale name. | |
104 | if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
105 | gt_cv_locale_fr=fr_FR | |
106 | else | |
107 | # Test for the locale name with explicit encoding suffix. | |
108 | if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
109 | gt_cv_locale_fr=fr_FR.ISO-8859-1 | |
110 | else | |
111 | # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. | |
112 | if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
113 | gt_cv_locale_fr=fr_FR.ISO8859-1 | |
114 | else | |
115 | # Test for the HP-UX locale name. | |
116 | if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
117 | gt_cv_locale_fr=fr_FR.iso88591 | |
118 | else | |
119 | # Test for the Solaris 7 locale name. | |
120 | if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
121 | gt_cv_locale_fr=fr | |
122 | else | |
123 | # None found. | |
124 | gt_cv_locale_fr=none | |
125 | fi | |
126 | fi | |
127 | fi | |
128 | fi | |
129 | fi | |
130 | ;; | |
131 | esac | |
132 | fi | |
133 | rm -fr conftest* | |
134 | ]) | |
135 | LOCALE_FR=$gt_cv_locale_fr | |
136 | AC_SUBST([LOCALE_FR]) | |
137 | ]) | |
138 | ||
139 | dnl Determine the name of a french locale with UTF-8 encoding. | |
140 | AC_DEFUN([gt_LOCALE_FR_UTF8], | |
141 | [ | |
142 | AC_REQUIRE([AM_LANGINFO_CODESET]) | |
143 | AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ | |
9c9d63b1 | 144 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
8690e634 JK |
145 | #include <locale.h> |
146 | #include <time.h> | |
147 | #if HAVE_LANGINFO_CODESET | |
148 | # include <langinfo.h> | |
149 | #endif | |
150 | #include <stdlib.h> | |
151 | #include <string.h> | |
152 | struct tm t; | |
153 | char buf[16]; | |
154 | int main () { | |
155 | /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl | |
156 | imitates locale dependent behaviour by looking at the environment | |
157 | variables, and all locales use the UTF-8 encoding. */ | |
158 | #if !(defined __BEOS__ || defined __HAIKU__) | |
159 | /* Check whether the given locale name is recognized by the system. */ | |
c0c3707f | 160 | # if defined _WIN32 && !defined __CYGWIN__ |
8690e634 JK |
161 | /* On native Windows, setlocale(category, "") looks at the system settings, |
162 | not at the environment variables. Also, when an encoding suffix such | |
163 | as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE | |
164 | category of the locale to "C". */ | |
165 | if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL | |
166 | || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) | |
167 | return 1; | |
168 | # else | |
169 | if (setlocale (LC_ALL, "") == NULL) return 1; | |
170 | # endif | |
171 | /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". | |
172 | On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) | |
173 | is empty, and the behaviour of Tcl 8.4 in this locale is not useful. | |
174 | On OpenBSD 4.0, when an unsupported locale is specified, setlocale() | |
175 | succeeds but then nl_langinfo(CODESET) is "646". In this situation, | |
176 | some unit tests fail. */ | |
177 | # if HAVE_LANGINFO_CODESET | |
178 | { | |
179 | const char *cs = nl_langinfo (CODESET); | |
180 | if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) | |
181 | return 1; | |
182 | } | |
183 | # endif | |
184 | # ifdef __CYGWIN__ | |
185 | /* On Cygwin, avoid locale names without encoding suffix, because the | |
186 | locale_charset() function relies on the encoding suffix. Note that | |
187 | LC_ALL is set on the command line. */ | |
188 | if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; | |
189 | # endif | |
190 | /* Check whether in the abbreviation of the second month, the second | |
191 | character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is | |
192 | two bytes long, with UTF-8 encoding. */ | |
193 | t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; | |
194 | if (strftime (buf, sizeof (buf), "%b", &t) < 4 | |
195 | || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') | |
196 | return 1; | |
197 | #endif | |
198 | #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ | |
199 | /* Check whether the decimal separator is a comma. | |
200 | On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point | |
201 | are nl_langinfo(RADIXCHAR) are both ".". */ | |
202 | if (localeconv () ->decimal_point[0] != ',') return 1; | |
203 | #endif | |
204 | return 0; | |
205 | } | |
9c9d63b1 | 206 | ]])]) |
8690e634 JK |
207 | if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then |
208 | case "$host_os" in | |
209 | # Handle native Windows specially, because there setlocale() interprets | |
210 | # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", | |
211 | # "fr" or "fra" as "French" or "French_France.1252", | |
212 | # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", | |
213 | # "ja" as "Japanese" or "Japanese_Japan.932", | |
214 | # and similar. | |
215 | mingw*) | |
216 | # Test for the hypothetical native Windows locale name. | |
217 | if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
218 | gt_cv_locale_fr_utf8=French_France.65001 | |
219 | else | |
220 | # None found. | |
221 | gt_cv_locale_fr_utf8=none | |
222 | fi | |
223 | ;; | |
224 | *) | |
225 | # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because | |
226 | # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the | |
227 | # configure script would override the LC_ALL setting. Likewise for | |
228 | # LC_CTYPE, which is also set at the beginning of the configure script. | |
229 | # Test for the usual locale name. | |
230 | if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
231 | gt_cv_locale_fr_utf8=fr_FR | |
232 | else | |
233 | # Test for the locale name with explicit encoding suffix. | |
234 | if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
235 | gt_cv_locale_fr_utf8=fr_FR.UTF-8 | |
236 | else | |
237 | # Test for the Solaris 7 locale name. | |
238 | if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | |
239 | gt_cv_locale_fr_utf8=fr.UTF-8 | |
240 | else | |
241 | # None found. | |
242 | gt_cv_locale_fr_utf8=none | |
243 | fi | |
244 | fi | |
245 | fi | |
246 | ;; | |
247 | esac | |
248 | fi | |
249 | rm -fr conftest* | |
250 | ]) | |
251 | LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 | |
252 | AC_SUBST([LOCALE_FR_UTF8]) | |
253 | ]) |