1 # locale-fr.m4 serial 20
2 dnl Copyright (C) 2003, 2005-2020 Free Software Foundation, Inc.
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.
9 dnl Determine the name of a french locale with traditional encoding.
10 AC_DEFUN([gt_LOCALE_FR],
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], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
18 #if HAVE_LANGINFO_CODESET
19 # include <langinfo.h>
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__
32 /* Check whether the given locale name is recognized by the system. */
33 # if defined _WIN32 && !defined __CYGWIN__
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)
42 if (setlocale (LC_ALL, "") == NULL) return 1;
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,
50 On MirBSD 10, when an unsupported locale is specified, setlocale()
51 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
52 # if HAVE_LANGINFO_CODESET
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)
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;
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;
71 # if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
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;
81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
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",
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
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
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
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
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
119 # Test for the Solaris 7 locale name.
120 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
135 LOCALE_FR=$gt_cv_locale_fr
136 AC_SUBST([LOCALE_FR])
139 dnl Determine the name of a french locale with UTF-8 encoding.
140 AC_DEFUN([gt_LOCALE_FR_UTF8],
142 AC_REQUIRE([AM_LANGINFO_CODESET])
143 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
144 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
147 #if HAVE_LANGINFO_CODESET
148 # include <langinfo.h>
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. */
160 # if defined _WIN32 && !defined __CYGWIN__
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)
169 if (setlocale (LC_ALL, "") == NULL) return 1;
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
179 const char *cs = nl_langinfo (CODESET);
180 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
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;
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')
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;
207 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
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",
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
221 gt_cv_locale_fr_utf8=none
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
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
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
242 gt_cv_locale_fr_utf8=none
251 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
252 AC_SUBST([LOCALE_FR_UTF8])