From eeb33ab8e350525f004888da1e5149a3794799f2 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 19 Mar 2023 22:50:56 +0800 Subject: [PATCH] Generate all UTF-8 locales Fixes #132 --- root/tmp/setup/php-extensions.sh | 5 ++--- tests/fixtures/test.php | 12 +++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/root/tmp/setup/php-extensions.sh b/root/tmp/setup/php-extensions.sh index 1617dac..2dcf959 100755 --- a/root/tmp/setup/php-extensions.sh +++ b/root/tmp/setup/php-extensions.sh @@ -34,10 +34,9 @@ apt-get install -y --no-install-recommends apt-transport-https \ $PACKAGES_MEMCACHED \ $PACKAGES_LDAP -# Generate the locales configuration fo rboth Australia, and the US. +# Generate the locales configuration for all possible UTF-8 locales. echo 'Generating locales..' -echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen -echo 'en_AU.UTF-8 UTF-8' >> /etc/locale.gen +grep UTF-8 /usr/share/i18n/SUPPORTED > /etc/locale.gen locale-gen echo "Installing php extensions" diff --git a/tests/fixtures/test.php b/tests/fixtures/test.php index 93cfff7..56f85e1 100644 --- a/tests/fixtures/test.php +++ b/tests/fixtures/test.php @@ -30,10 +30,16 @@ } } -$locale = 'en_AU.UTF-8'; -if (setlocale(LC_TIME, $locale) === false) { - $missing[] = $locale; +$locales = [ + 'en_AU.UTF-8', + 'es_ES.UTF-8', +]; +foreach ($locales as $locale) { + if (setlocale(LC_TIME, $locale) === false) { + $missing[] = $locale; + } } +setlocale(LC_TIME, 'en_AU.UTF-8'); if (php_sapi_name() === 'cli') { if (empty($missing)) {