1# locale-fr.m4 serial 7 2dnl Copyright (C) 2003, 2005-2007 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= 16changequote(,)dnl 17 case "$host_os" in 18 darwin[56]*) ;; 19 darwin*) macosx=yes;; 20 esac 21changequote([,])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([ 34changequote(,)dnl 35#include <locale.h> 36#include <time.h> 37#if HAVE_LANGINFO_CODESET 38# include <langinfo.h> 39#endif 40#include <stdlib.h> 41#include <string.h> 42struct tm t; 43char buf[16]; 44int main () { 45 /* Check whether the given locale name is recognized by the system. */ 46 if (setlocale (LC_ALL, "") == NULL) return 1; 47 /* Check whether nl_langinfo(CODESET) is nonempty. 48 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 49 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. */ 50#if HAVE_LANGINFO_CODESET 51 if (nl_langinfo (CODESET) [0] == '\0') return 1; 52#endif 53#ifdef __CYGWIN__ 54 /* On Cygwin, avoid locale names without encoding suffix, because the 55 locale_charset() function relies on the encoding suffix. Note that 56 LC_ALL is set on the command line. */ 57 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 58#endif 59 /* Check whether in the abbreviation of the second month, the second 60 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only 61 one byte long. This excludes the UTF-8 encoding. */ 62 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 63 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 64 /* Check whether the decimal separator is a comma. 65 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 66 are nl_langinfo(RADIXCHAR) are both ".". */ 67 if (localeconv () ->decimal_point[0] != ',') return 1; 68 return 0; 69} 70changequote([,])dnl 71 ])]) 72 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 73 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 74 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 75 # configure script would override the LC_ALL setting. Likewise for 76 # LC_CTYPE, which is also set at the beginning of the configure script. 77 # Test for the usual locale name. 78 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 79 gt_cv_locale_fr=fr_FR 80 else 81 # Test for the locale name with explicit encoding suffix. 82 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 83 gt_cv_locale_fr=fr_FR.ISO-8859-1 84 else 85 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. 86 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 87 gt_cv_locale_fr=fr_FR.ISO8859-1 88 else 89 # Test for the HP-UX locale name. 90 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 91 gt_cv_locale_fr=fr_FR.iso88591 92 else 93 # Test for the Solaris 7 locale name. 94 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 95 gt_cv_locale_fr=fr 96 else 97 # None found. 98 gt_cv_locale_fr=none 99 fi 100 fi 101 fi 102 fi 103 fi 104 fi 105 rm -fr conftest* 106 fi 107 ]) 108 LOCALE_FR=$gt_cv_locale_fr 109 AC_SUBST([LOCALE_FR]) 110]) 111 112dnl Determine the name of a french locale with UTF-8 encoding. 113AC_DEFUN([gt_LOCALE_FR_UTF8], 114[ 115 AC_REQUIRE([AM_LANGINFO_CODESET]) 116 AC_CACHE_CHECK([for a french Unicode locale], gt_cv_locale_fr_utf8, [ 117 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 118changequote(,)dnl 119#include <locale.h> 120#include <time.h> 121#if HAVE_LANGINFO_CODESET 122# include <langinfo.h> 123#endif 124#include <stdlib.h> 125#include <string.h> 126struct tm t; 127char buf[16]; 128int main () { 129 /* On BeOS, locales are not implemented in libc. Rather, libintl 130 imitates locale dependent behaviour by looking at the environment 131 variables, and all locales use the UTF-8 encoding. */ 132#if !defined(__BEOS__) 133 /* Check whether the given locale name is recognized by the system. */ 134 if (setlocale (LC_ALL, "") == NULL) return 1; 135 /* Check whether nl_langinfo(CODESET) is nonempty. 136 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 137 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. */ 138# if HAVE_LANGINFO_CODESET 139 if (nl_langinfo (CODESET) [0] == '\0') return 1; 140# endif 141# ifdef __CYGWIN__ 142 /* On Cygwin, avoid locale names without encoding suffix, because the 143 locale_charset() function relies on the encoding suffix. Note that 144 LC_ALL is set on the command line. */ 145 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 146# endif 147 /* Check whether in the abbreviation of the second month, the second 148 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is 149 two bytes long, with UTF-8 encoding. */ 150 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 151 if (strftime (buf, sizeof (buf), "%b", &t) < 4 152 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') 153 return 1; 154#endif 155 /* Check whether the decimal separator is a comma. 156 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 157 are nl_langinfo(RADIXCHAR) are both ".". */ 158 if (localeconv () ->decimal_point[0] != ',') return 1; 159 return 0; 160} 161changequote([,])dnl 162 ])]) 163 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 164 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 165 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 166 # configure script would override the LC_ALL setting. Likewise for 167 # LC_CTYPE, which is also set at the beginning of the configure script. 168 # Test for the usual locale name. 169 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 170 gt_cv_locale_fr_utf8=fr_FR 171 else 172 # Test for the locale name with explicit encoding suffix. 173 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 174 gt_cv_locale_fr_utf8=fr_FR.UTF-8 175 else 176 # Test for the Solaris 7 locale name. 177 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 178 gt_cv_locale_fr_utf8=fr.UTF-8 179 else 180 # None found. 181 gt_cv_locale_fr_utf8=none 182 fi 183 fi 184 fi 185 fi 186 rm -fr conftest* 187 ]) 188 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 189 AC_SUBST([LOCALE_FR_UTF8]) 190]) 191