1# locale-fr.m4 serial 3 (gettext-0.15)
2dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Determine the name of a french locale with traditional encoding.
10AC_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    case "$host_os" in
17      darwin[56]*) ;;
18      darwin*) macosx=yes;;
19    esac
20    if test -n "$macosx"; then
21      # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
22      # encodings, but the kernel does not support them. The documentation
23      # says:
24      #   "... all code that calls BSD system routines should ensure
25      #    that the const *char parameters of these routines are in UTF-8
26      #    encoding. All BSD system functions expect their string
27      #    parameters to be in UTF-8 encoding and nothing else."
28      # See the comments in config.charset. Therefore we bypass the test.
29      gt_cv_locale_fr=none
30    else
31      AC_LANG_CONFTEST([AC_LANG_SOURCE([
32changequote(,)dnl
33#include <locale.h>
34#include <time.h>
35#if HAVE_LANGINFO_CODESET
36# include <langinfo.h>
37#endif
38struct tm t;
39char buf[16];
40int main () {
41  /* Check whether the given locale name is recognized by the system.  */
42  if (setlocale (LC_ALL, "") == NULL) return 1;
43  /* Check whether nl_langinfo(CODESET) is nonempty.
44     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
45     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
46#if HAVE_LANGINFO_CODESET
47  if (nl_langinfo (CODESET) [0] == '\0') return 1;
48#endif
49  /* Check whether in the abbreviation of the second month, the second
50     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
51     one byte long. This excludes the UTF-8 encoding.  */
52  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
53  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
54  return 0;
55}
56changequote([,])dnl
57        ])])
58      if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
59        # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
60        # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
61        # configure script would override the LC_ALL setting. Likewise for
62        # LC_CTYPE, which is also set at the beginning of the configure script.
63        # Test for the usual locale name.
64        if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
65          gt_cv_locale_fr=fr_FR
66        else
67          # Test for the locale name with explicit encoding suffix.
68          if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
69            gt_cv_locale_fr=fr_FR.ISO-8859-1
70          else
71            # Test for the AIX, OSF/1, FreeBSD, NetBSD locale name.
72            if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
73              gt_cv_locale_fr=fr_FR.ISO8859-1
74            else
75              # Test for the HP-UX locale name.
76              if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
77                gt_cv_locale_fr=fr_FR.iso88591
78              else
79                # Test for the Solaris 7 locale name.
80                if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
81                  gt_cv_locale_fr=fr
82                else
83                  # Special test for NetBSD 1.6.
84                  if test -f /usr/share/locale/fr_FR.ISO8859-1/LC_CTYPE; then
85                    gt_cv_locale_fr=fr_FR.ISO8859-1
86                  else
87                    # None found.
88                    gt_cv_locale_fr=none
89                  fi
90                fi
91              fi
92            fi
93          fi
94        fi
95      fi
96      rm -fr conftest*
97    fi
98  ])
99  LOCALE_FR=$gt_cv_locale_fr
100  AC_SUBST([LOCALE_FR])
101])
102
103dnl Determine the name of a french locale with UTF-8 encoding.
104AC_DEFUN([gt_LOCALE_FR_UTF8],
105[
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([
109changequote(,)dnl
110#include <locale.h>
111#include <time.h>
112#if HAVE_LANGINFO_CODESET
113# include <langinfo.h>
114#endif
115struct tm t;
116char buf[16];
117int main () {
118  /* On BeOS, locales are not implemented in libc.  Rather, libintl
119     imitates locale dependent behaviour by looking at the environment
120     variables, and all locales use the UTF-8 encoding.  */
121#if !defined(__BEOS__)
122  /* Check whether the given locale name is recognized by the system.  */
123  if (setlocale (LC_ALL, "") == NULL) return 1;
124  /* Check whether nl_langinfo(CODESET) is nonempty.
125     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
126     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.  */
127# if HAVE_LANGINFO_CODESET
128  if (nl_langinfo (CODESET) [0] == '\0') return 1;
129# endif
130  /* Check whether in the abbreviation of the second month, the second
131     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
132     two bytes long, with UTF-8 encoding.  */
133  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
134  if (strftime (buf, sizeof (buf), "%b", &t) < 4
135      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
136    return 1;
137#endif
138  return 0;
139}
140changequote([,])dnl
141      ])])
142    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
143      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
144      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
145      # configure script would override the LC_ALL setting. Likewise for
146      # LC_CTYPE, which is also set at the beginning of the configure script.
147      # Test for the usual locale name.
148      if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
149        gt_cv_locale_fr_utf8=fr_FR
150      else
151        # Test for the locale name with explicit encoding suffix.
152        if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
153          gt_cv_locale_fr_utf8=fr_FR.UTF-8
154        else
155          # Test for the Solaris 7 locale name.
156          if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
157            gt_cv_locale_fr_utf8=fr.UTF-8
158          else
159            # None found.
160            gt_cv_locale_fr_utf8=none
161          fi
162        fi
163      fi
164    fi
165    rm -fr conftest*
166  ])
167  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
168  AC_SUBST([LOCALE_FR_UTF8])
169])
170