a33f0680dd648ba2e71538b88437a044835cc137
[gnulib.git] / m4 / locale-fr.m4
1 # locale-fr.m4 serial 6 (gettext-0.16.2)
2 dnl Copyright (C) 2003, 2005-2007 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.
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, [
15     macosx=
16 changequote(,)dnl
17     case "$host_os" in
18       darwin[56]*) ;;
19       darwin*) macosx=yes;;
20     esac
21 changequote([,])dnl
22     if test -n "$macosx"; then
23       # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
24       # encodings, but the kernel does not support them. The documentation
25       # says:
26       #   "... all code that calls BSD system routines should ensure
27       #    that the const *char parameters of these routines are in UTF-8
28       #    encoding. All BSD system functions expect their string
29       #    parameters to be in UTF-8 encoding and nothing else."
30       # See the comments in config.charset. Therefore we bypass the test.
31       gt_cv_locale_fr=none
32     else
33       AC_LANG_CONFTEST([AC_LANG_SOURCE([
34 changequote(,)dnl
35 #include <locale.h>
36 #include <time.h>
37 #if HAVE_LANGINFO_CODESET
38 # include <langinfo.h>
39 #endif
40 struct tm t;
41 char buf[16];
42 int main () {
43   /* Check whether the given locale name is recognized by the system.  */
44   if (setlocale (LC_ALL, "") == NULL) return 1;
45   /* Check whether nl_langinfo(CODESET) is nonempty.
46      On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
47      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
48 #if HAVE_LANGINFO_CODESET
49   if (nl_langinfo (CODESET) [0] == '\0') return 1;
50 #endif
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;
60   return 0;
61 }
62 changequote([,])dnl
63         ])])
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
71           gt_cv_locale_fr=fr_FR
72         else
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
76           else
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
80             else
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
84               else
85                 # Test for the Solaris 7 locale name.
86                 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
87                   gt_cv_locale_fr=fr
88                 else
89                   # None found.
90                   gt_cv_locale_fr=none
91                 fi
92               fi
93             fi
94           fi
95         fi
96       fi
97       rm -fr conftest*
98     fi
99   ])
100   LOCALE_FR=$gt_cv_locale_fr
101   AC_SUBST([LOCALE_FR])
102 ])
103
104 dnl Determine the name of a french locale with UTF-8 encoding.
105 AC_DEFUN([gt_LOCALE_FR_UTF8],
106 [
107   AC_REQUIRE([AM_LANGINFO_CODESET])
108   AC_CACHE_CHECK([for a french Unicode locale], gt_cv_locale_fr_utf8, [
109     AC_LANG_CONFTEST([AC_LANG_SOURCE([
110 changequote(,)dnl
111 #include <locale.h>
112 #include <time.h>
113 #if HAVE_LANGINFO_CODESET
114 # include <langinfo.h>
115 #endif
116 struct tm t;
117 char buf[16];
118 int main () {
119   /* On BeOS, locales are not implemented in libc.  Rather, libintl
120      imitates locale dependent behaviour by looking at the environment
121      variables, and all locales use the UTF-8 encoding.  */
122 #if !defined(__BEOS__)
123   /* Check whether the given locale name is recognized by the system.  */
124   if (setlocale (LC_ALL, "") == NULL) return 1;
125   /* Check whether nl_langinfo(CODESET) is nonempty.
126      On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
127      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
128 # if HAVE_LANGINFO_CODESET
129   if (nl_langinfo (CODESET) [0] == '\0') return 1;
130 # endif
131   /* Check whether in the abbreviation of the second month, the second
132      character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
133      two bytes long, with UTF-8 encoding.  */
134   t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
135   if (strftime (buf, sizeof (buf), "%b", &t) < 4
136       || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
137     return 1;
138 #endif
139   /* Check whether the decimal separator is a comma.
140      On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
141      are nl_langinfo(RADIXCHAR) are both ".".  */
142   if (localeconv () ->decimal_point[0] != ',') return 1;
143   return 0;
144 }
145 changequote([,])dnl
146       ])])
147     if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
148       # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
149       # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
150       # configure script would override the LC_ALL setting. Likewise for
151       # LC_CTYPE, which is also set at the beginning of the configure script.
152       # Test for the usual locale name.
153       if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
154         gt_cv_locale_fr_utf8=fr_FR
155       else
156         # Test for the locale name with explicit encoding suffix.
157         if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
158           gt_cv_locale_fr_utf8=fr_FR.UTF-8
159         else
160           # Test for the Solaris 7 locale name.
161           if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
162             gt_cv_locale_fr_utf8=fr.UTF-8
163           else
164             # None found.
165             gt_cv_locale_fr_utf8=none
166           fi
167         fi
168       fi
169     fi
170     rm -fr conftest*
171   ])
172   LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
173   AC_SUBST([LOCALE_FR_UTF8])
174 ])