From 57009be2b8bac13bd11d8844f826375456f5a810 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Fri, 24 Jun 2022 18:25:44 +0200 Subject: [PATCH] Fix intl on Alpine 3.16 by installing icu-data-full (#605) --- install-php-extensions | 14 ++++++++++---- scripts/tests/intl | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 scripts/tests/intl diff --git a/install-php-extensions b/install-php-extensions index 1abcf2c..b3e6104 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -608,6 +608,10 @@ buildRequiredPackageLists() { else buildRequiredPackageLists_libssldev='libretls-dev' fi + buildRequiredPackageLists_icuPersistent='' + if test $DISTRO_MAJMIN_VERSION -ge 316; then + buildRequiredPackageLists_icuPersistent='icu-data-full' + fi ;; debian@9) buildRequiredPackageLists_libssldev='libssl1.0-dev' @@ -824,7 +828,7 @@ buildRequiredPackageLists() { buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libidn" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libidn-dev" else - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs libidn" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs $buildRequiredPackageLists_icuPersistent libidn" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile icu-dev libidn-dev" fi ;; @@ -870,7 +874,7 @@ buildRequiredPackageLists() { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile firebird-dev libib-util" ;; intl@alpine) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs $buildRequiredPackageLists_icuPersistent" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile icu-dev" ;; intl@debian) @@ -955,7 +959,7 @@ buildRequiredPackageLists() { buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile $buildRequiredPackageLists_libssldev libsasl2-dev" ;; mongodb@alpine) - buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs libsasl $buildRequiredPackageLists_libssl snappy" + buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent icu-libs $buildRequiredPackageLists_icuPersistent libsasl $buildRequiredPackageLists_libssl snappy" buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile icu-dev cyrus-sasl-dev snappy-dev $buildRequiredPackageLists_libssldev zlib-dev" ;; mongodb@debian) @@ -1361,7 +1365,9 @@ buildRequiredPackageLists() { resetIFS for buildRequiredPackageLists_package in $buildRequiredPackageLists_packages; do if ! stringInList "$buildRequiredPackageLists_package" "$PACKAGES_PERSISTENT_NEW"; then - PACKAGES_VOLATILE="$PACKAGES_VOLATILE $buildRequiredPackageLists_package" + if test "$buildRequiredPackageLists_package" != icu-data-en || ! stringInList icu-data-full "$PACKAGES_PERSISTENT_NEW"; then + PACKAGES_VOLATILE="$PACKAGES_VOLATILE $buildRequiredPackageLists_package" + fi fi done PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }" diff --git a/scripts/tests/intl b/scripts/tests/intl new file mode 100755 index 0000000..2b50bbb --- /dev/null +++ b/scripts/tests/intl @@ -0,0 +1,22 @@ +#!/usr/bin/env php + "\xC2\xA4#,##0.00", + 'it' => "#,##0.00\xC2\xA0\xC2\xA4", +] as $locale => $expectedCurrencyFormat) { + echo "- {$locale}: "; + $formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY); + $actualCurrencyFormat = $formatter->getPattern(); + if ($actualCurrencyFormat === $expectedCurrencyFormat) { + echo "ok\n"; + } else { + echo "failed (expected: '{$expectedCurrencyFormat}', actual: '{$actualCurrencyFormat}')\n"; + $rc = 1; + } +} +exit($rc);