1 # locale-fr.m4 serial 12
2 dnl Copyright (C) 2003, 2005-2010 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([
19 #if HAVE_LANGINFO_CODESET
20 # include <langinfo.h>
27 /* Check whether the given locale name is recognized by the system. */
28 if (setlocale (LC_ALL, "") == NULL) return 1;
29 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
30 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
31 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
32 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
33 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
35 On MirBSD 10, when an unsupported locale is specified, setlocale()
36 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
37 #if HAVE_LANGINFO_CODESET
39 const char *cs = nl_langinfo (CODESET);
40 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
41 || strcmp (cs, "UTF-8") == 0)
46 /* On Cygwin, avoid locale names without encoding suffix, because the
47 locale_charset() function relies on the encoding suffix. Note that
48 LC_ALL is set on the command line. */
49 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
51 /* Check whether in the abbreviation of the second month, the second
52 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
53 one byte long. This excludes the UTF-8 encoding. */
54 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
55 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
56 /* Check whether the decimal separator is a comma.
57 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
58 are nl_langinfo(RADIXCHAR) are both ".". */
59 if (localeconv () ->decimal_point[0] != ',') return 1;
64 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
65 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
66 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
67 # configure script would override the LC_ALL setting. Likewise for
68 # LC_CTYPE, which is also set at the beginning of the configure script.
69 # Test for the usual locale name.
70 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
73 # Test for the locale name with explicit encoding suffix.
74 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
75 gt_cv_locale_fr=fr_FR.ISO-8859-1
77 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
78 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
79 gt_cv_locale_fr=fr_FR.ISO8859-1
81 # Test for the HP-UX locale name.
82 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
83 gt_cv_locale_fr=fr_FR.iso88591
85 # Test for the Solaris 7 locale name.
86 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
99 LOCALE_FR=$gt_cv_locale_fr
100 AC_SUBST([LOCALE_FR])
103 dnl Determine the name of a french locale with UTF-8 encoding.
104 AC_DEFUN([gt_LOCALE_FR_UTF8],
106 AC_REQUIRE([AM_LANGINFO_CODESET])
107 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
108 AC_LANG_CONFTEST([AC_LANG_SOURCE([
112 #if HAVE_LANGINFO_CODESET
113 # include <langinfo.h>
120 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
121 imitates locale dependent behaviour by looking at the environment
122 variables, and all locales use the UTF-8 encoding. */
123 #if !(defined __BEOS__ || defined __HAIKU__)
124 /* Check whether the given locale name is recognized by the system. */
125 if (setlocale (LC_ALL, "") == NULL) return 1;
126 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
127 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
128 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
129 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
130 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
131 some unit tests fail. */
132 # if HAVE_LANGINFO_CODESET
134 const char *cs = nl_langinfo (CODESET);
135 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
140 /* On Cygwin, avoid locale names without encoding suffix, because the
141 locale_charset() function relies on the encoding suffix. Note that
142 LC_ALL is set on the command line. */
143 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
145 /* Check whether in the abbreviation of the second month, the second
146 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
147 two bytes long, with UTF-8 encoding. */
148 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
149 if (strftime (buf, sizeof (buf), "%b", &t) < 4
150 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
153 /* Check whether the decimal separator is a comma.
154 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
155 are nl_langinfo(RADIXCHAR) are both ".". */
156 if (localeconv () ->decimal_point[0] != ',') return 1;
161 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
162 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
163 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
164 # configure script would override the LC_ALL setting. Likewise for
165 # LC_CTYPE, which is also set at the beginning of the configure script.
166 # Test for the usual locale name.
167 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
168 gt_cv_locale_fr_utf8=fr_FR
170 # Test for the locale name with explicit encoding suffix.
171 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
172 gt_cv_locale_fr_utf8=fr_FR.UTF-8
174 # Test for the Solaris 7 locale name.
175 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
176 gt_cv_locale_fr_utf8=fr.UTF-8
179 gt_cv_locale_fr_utf8=none
186 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
187 AC_SUBST([LOCALE_FR_UTF8])