Skip to content

Commit 8a6b172

Browse files
committed
ext/gettext/config.m4: copy en_US.UTF-8 test bits to en_US for musl
The gettext() family of functions under musl does not support codeset suffixes like ".UTF-8", because the only codeset it understands is UTF-8. (Yes, it is annoying that it doesn't support the suffix for the codeset that it does understand; no, I am not in charge.) Thanks to this, we have six failing tests on musl, * FAIL Gettext basic test with en_US locale that should be on nearly every system [ext/gettext/tests/gettext_basic-enus.phpt] * FAIL Test if bindtextdomain() returns string id if no directory path is set( if directory path is 'null') [ext/gettext/tests/gettext_bindtextdomain-cwd.phpt] * FAIL Test dcgettext() functionality [ext/gettext/tests/gettext_dcgettext.phpt] * FAIL Test dgettext() functionality [ext/gettext/tests/gettext_dgettext.phpt] * FAIL Test if dngettext() returns the correct translations (optionally plural). [ext/gettext/tests/gettext_dngettext-plural.phpt] * FAIL Test ngettext() functionality [ext/gettext/tests/gettext_ngettext.phpt] These are all fixed by copying the en_US.UTF-8 message data to en_US, where musl is able to find it. This does not make the situation any better for developers (who don't know what libc their users will be running), but that problem is inhereted from C and is not the fault of the gettext extension. This partially addresses GH #13696
1 parent eebd90d commit 8a6b172

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ext/gettext/config.m4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ if test "$PHP_GETTEXT" != "no"; then
2323
[AC_CHECK_LIB([c], [bindtextdomain], [
2424
GETTEXT_LIBS=
2525
GETTEXT_CHECK_IN_LIB=c
26+
27+
dnl If libintl.h is provided by libc, it's possible that libc is musl.
28+
dnl The gettext family of functions under musl ignores the codeset
29+
dnl suffix on directories like "en_US.UTF-8"; instead they look only
30+
dnl in "en_US". To accomodate that, we copy some test cases from one
31+
dnl to the other.
32+
AC_MSG_NOTICE([copying en_US.UTF-8 messages to en_US in case you are on musl])
33+
mkdir -p "${srcdir%/}"/ext/gettext/tests/locale/en_US
34+
cp -r "${srcdir%/}"/ext/gettext/tests/locale/en_US.UTF-8/* "${srcdir%/}"/ext/gettext/tests/locale/en_US/
2635
],
2736
[AC_MSG_FAILURE([Unable to find required intl library for gettext.])])])
2837

0 commit comments

Comments
 (0)