diff options
Diffstat (limited to 'gl/m4/locale-en.m4')
| -rw-r--r-- | gl/m4/locale-en.m4 | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/gl/m4/locale-en.m4 b/gl/m4/locale-en.m4 new file mode 100644 index 00000000..4151428a --- /dev/null +++ b/gl/m4/locale-en.m4 | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | # locale-en.m4 | ||
| 2 | # serial 1 | ||
| 3 | dnl Copyright (C) 2003-2025 Free Software Foundation, Inc. | ||
| 4 | dnl This file is free software; the Free Software Foundation | ||
| 5 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 6 | dnl with or without modifications, as long as this notice is preserved. | ||
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 8 | |||
| 9 | dnl From Bruno Haible. | ||
| 10 | |||
| 11 | dnl Determine the name of an English (or American English) locale with | ||
| 12 | dnl UTF-8 encoding. | ||
| 13 | AC_DEFUN_ONCE([gt_LOCALE_EN_UTF8], | ||
| 14 | [ | ||
| 15 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| 16 | AC_REQUIRE([AM_LANGINFO_CODESET]) | ||
| 17 | AC_CACHE_CHECK([for an english Unicode locale], [gt_cv_locale_en_utf8], [ | ||
| 18 | case "$host_os" in | ||
| 19 | *-musl* | midipix*) | ||
| 20 | dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without | ||
| 21 | dnl any locale file on disk. But they are effectively equivalent to the | ||
| 22 | dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES) | ||
| 23 | dnl for which localizations (.mo files) have been installed. | ||
| 24 | gt_cv_locale_en_utf8=en_US.UTF-8 | ||
| 25 | ;; | ||
| 26 | *) | ||
| 27 | AC_LANG_CONFTEST([AC_LANG_SOURCE([[ | ||
| 28 | #include <locale.h> | ||
| 29 | #include <time.h> | ||
| 30 | #if HAVE_LANGINFO_CODESET | ||
| 31 | # include <langinfo.h> | ||
| 32 | #endif | ||
| 33 | #include <stdlib.h> | ||
| 34 | #include <string.h> | ||
| 35 | struct tm t; | ||
| 36 | char buf[16]; | ||
| 37 | int main () { | ||
| 38 | /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl | ||
| 39 | imitates locale dependent behaviour by looking at the environment | ||
| 40 | variables, and all locales use the UTF-8 encoding. */ | ||
| 41 | #if !(defined __BEOS__ || defined __HAIKU__) | ||
| 42 | /* Check whether the given locale name is recognized by the system. */ | ||
| 43 | # if defined _WIN32 && !defined __CYGWIN__ | ||
| 44 | /* On native Windows, setlocale(category, "") looks at the system settings, | ||
| 45 | not at the environment variables. Also, when an encoding suffix such | ||
| 46 | as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE | ||
| 47 | category of the locale to "C". */ | ||
| 48 | if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL | ||
| 49 | || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) | ||
| 50 | return 1; | ||
| 51 | # else | ||
| 52 | if (setlocale (LC_ALL, "") == NULL) return 1; | ||
| 53 | # endif | ||
| 54 | /* Check whether nl_langinfo(CODESET) is "UTF-8" or equivalent. */ | ||
| 55 | # if HAVE_LANGINFO_CODESET | ||
| 56 | { | ||
| 57 | const char *cs = nl_langinfo (CODESET); | ||
| 58 | if (!(strcmp (cs, "UTF-8") == 0 || strcmp (cs, "UTF8") == 0 | ||
| 59 | || strcmp (cs, "utf-8") == 0 || strcmp (cs, "utf8") == 0)) | ||
| 60 | return 1; | ||
| 61 | } | ||
| 62 | # endif | ||
| 63 | # ifdef __CYGWIN__ | ||
| 64 | /* On Cygwin, avoid locale names without encoding suffix, because the | ||
| 65 | locale_charset() function relies on the encoding suffix. Note that | ||
| 66 | LC_ALL is set on the command line. */ | ||
| 67 | if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; | ||
| 68 | # endif | ||
| 69 | /* Check the third month name. */ | ||
| 70 | t.tm_year = 1975 - 1900; t.tm_mon = 3 - 1; t.tm_mday = 24; | ||
| 71 | if (strftime (buf, sizeof (buf), "%B", &t) < 5 || strcmp (buf, "March") != 0) | ||
| 72 | return 1; | ||
| 73 | #endif | ||
| 74 | #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ | ||
| 75 | /* Check whether the decimal separator is a dot. */ | ||
| 76 | if (localeconv () ->decimal_point[0] != '.') return 1; | ||
| 77 | #endif | ||
| 78 | return 0; | ||
| 79 | } | ||
| 80 | ]])]) | ||
| 81 | if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then | ||
| 82 | case "$host_os" in | ||
| 83 | # Handle native Windows specially, because there setlocale() interprets | ||
| 84 | # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256", | ||
| 85 | # "en" or "eng" as "English" or "English_United States.1252", | ||
| 86 | # "fr" or "fra" as "French" or "French_France.1252", | ||
| 87 | # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", | ||
| 88 | # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932", | ||
| 89 | # and similar. | ||
| 90 | mingw* | windows*) | ||
| 91 | # Test for the hypothetical native Windows locale name. | ||
| 92 | if (LC_ALL='English_United States.65001' LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | ||
| 93 | gt_cv_locale_en_utf8='English_United States.65001' | ||
| 94 | else | ||
| 95 | # None found. | ||
| 96 | gt_cv_locale_en_utf8=none | ||
| 97 | fi | ||
| 98 | ;; | ||
| 99 | *) | ||
| 100 | # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because | ||
| 101 | # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the | ||
| 102 | # configure script would override the LC_ALL setting. Likewise for | ||
| 103 | # LC_CTYPE, which is also set at the beginning of the configure script. | ||
| 104 | # Test for the locale name with explicit encoding suffix first | ||
| 105 | # (this is necessary on Haiku). | ||
| 106 | if (LC_ALL=en_US.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | ||
| 107 | gt_cv_locale_en_utf8=en_US.UTF-8 | ||
| 108 | else | ||
| 109 | # Test for the locale name without encoding suffix. | ||
| 110 | if (LC_ALL=en_US LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | ||
| 111 | gt_cv_locale_en_utf8=en_US | ||
| 112 | else | ||
| 113 | # Test for the Solaris 10 locale name. | ||
| 114 | if (LC_ALL=en.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then | ||
| 115 | gt_cv_locale_en_utf8=en.UTF-8 | ||
| 116 | else | ||
| 117 | # None found. | ||
| 118 | gt_cv_locale_en_utf8=none | ||
| 119 | fi | ||
| 120 | fi | ||
| 121 | fi | ||
| 122 | ;; | ||
| 123 | esac | ||
| 124 | fi | ||
| 125 | rm -fr conftest* | ||
| 126 | ;; | ||
| 127 | esac | ||
| 128 | ]) | ||
| 129 | LOCALE_EN_UTF8="$gt_cv_locale_en_utf8" | ||
| 130 | case "$LOCALE_EN_UTF8" in #( | ||
| 131 | '' | *[[\"\$\'*@<:@]]*) | ||
| 132 | dnl The empty value occurs when the conftest.c program above could not | ||
| 133 | dnl be compiled. The other values might cause trouble with sh or make. | ||
| 134 | AC_MSG_WARN([invalid locale "$LOCALE_EN_UTF8"; assuming "none"]) | ||
| 135 | LOCALE_EN_UTF8=none;; | ||
| 136 | esac | ||
| 137 | AC_SUBST([LOCALE_EN_UTF8]) | ||
| 138 | ]) | ||
