diff --git a/src/SPC/builder/extension/gettext.php b/src/SPC/builder/extension/gettext.php index 19f48f7e..8b29a111 100644 --- a/src/SPC/builder/extension/gettext.php +++ b/src/SPC/builder/extension/gettext.php @@ -16,12 +16,21 @@ class gettext extends Extension { /** * @throws FileSystemException + */ + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl'); + return true; + } + + /** * @throws WrongUsageException + * @throws FileSystemException */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lintl/', $this->getLibFilesString() . $frameworks); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks); return true; } } diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 90e6dcfc..3b2dbb30 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -16,6 +16,7 @@ trait gettext '--enable-static ' . '--disable-shared ' . '--disable-java ' . + '--disable-c+ ' . $extra . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--prefix=' . BUILD_ROOT_PATH diff --git a/src/globals/objs/test.mo b/src/globals/objs/test.mo deleted file mode 100644 index 208349ee..00000000 Binary files a/src/globals/objs/test.mo and /dev/null differ diff --git a/src/globals/tests/gettext.php b/src/globals/tests/gettext.php index dacc512c..c161d682 100644 --- a/src/globals/tests/gettext.php +++ b/src/globals/tests/gettext.php @@ -4,13 +4,15 @@ declare(strict_types=1); assert(function_exists('gettext')); assert(function_exists('bindtextdomain')); +assert(function_exists('textdomain')); assert(function_exists('bind_textdomain_codeset')); if (!is_dir('locale/en_US/LC_MESSAGES/')) { mkdir('locale/en_US/LC_MESSAGES/', 0755, true); } if (!file_exists('locale/en_US/LC_MESSAGES/test.mo')) { - file_put_contents('locale/en_US/LC_MESSAGES/test.mo', file_get_contents(__DIR__ . '/../objs/test.mo')); + $mo = '3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABgAAAFEAAAAXAQAAWAAAAAcAAABwAQAAAQAAAAAAAAAAAAAAAgAAAAAAAAAA56S65L6LAFByb2plY3QtSWQtVmVyc2lvbjogUEFDS0FHRSBWRVJTSU9OClJlcG9ydC1Nc2dpZC1CdWdzLVRvOiAKUE8tUmV2aXNpb24tRGF0ZTogWUVBUi1NTy1EQSBITzpNSStaT05FCkxhc3QtVHJhbnNsYXRvcjogRlVMTCBOQU1FIDxFTUFJTEBBRERSRVNTPgpMYW5ndWFnZS1UZWFtOiBMQU5HVUFHRSA8TExAbGkub3JnPgpMYW5ndWFnZTogCk1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0CgBFeGFtcGxlAA=='; + file_put_contents('locale/en_US/LC_MESSAGES/test.mo', base64_decode($mo)); } putenv('LANG=en_US'); setlocale(LC_ALL, 'en_US'); @@ -20,4 +22,4 @@ bindtextdomain($domain, 'locale/'); bind_textdomain_codeset($domain, 'UTF-8'); textdomain($domain); -assert(gettext('示例') === 'Example'); +assert(gettext(json_decode('"\u793a\u4f8b"', true)) === 'Example');