mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
fix gettext build
This commit is contained in:
parent
71c0387ab0
commit
49ddb3ec13
@ -16,12 +16,21 @@ class gettext extends Extension
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @throws FileSystemException
|
* @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 WrongUsageException
|
||||||
|
* @throws FileSystemException
|
||||||
*/
|
*/
|
||||||
public function patchBeforeConfigure(): bool
|
public function patchBeforeConfigure(): bool
|
||||||
{
|
{
|
||||||
$frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : '';
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ trait gettext
|
|||||||
'--enable-static ' .
|
'--enable-static ' .
|
||||||
'--disable-shared ' .
|
'--disable-shared ' .
|
||||||
'--disable-java ' .
|
'--disable-java ' .
|
||||||
|
'--disable-c+ ' .
|
||||||
$extra .
|
$extra .
|
||||||
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
|
'--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||||
'--prefix=' . BUILD_ROOT_PATH
|
'--prefix=' . BUILD_ROOT_PATH
|
||||||
|
|||||||
Binary file not shown.
@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
assert(function_exists('gettext'));
|
assert(function_exists('gettext'));
|
||||||
assert(function_exists('bindtextdomain'));
|
assert(function_exists('bindtextdomain'));
|
||||||
|
assert(function_exists('textdomain'));
|
||||||
assert(function_exists('bind_textdomain_codeset'));
|
assert(function_exists('bind_textdomain_codeset'));
|
||||||
|
|
||||||
if (!is_dir('locale/en_US/LC_MESSAGES/')) {
|
if (!is_dir('locale/en_US/LC_MESSAGES/')) {
|
||||||
mkdir('locale/en_US/LC_MESSAGES/', 0755, true);
|
mkdir('locale/en_US/LC_MESSAGES/', 0755, true);
|
||||||
}
|
}
|
||||||
if (!file_exists('locale/en_US/LC_MESSAGES/test.mo')) {
|
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');
|
putenv('LANG=en_US');
|
||||||
setlocale(LC_ALL, 'en_US');
|
setlocale(LC_ALL, 'en_US');
|
||||||
@ -20,4 +22,4 @@ bindtextdomain($domain, 'locale/');
|
|||||||
bind_textdomain_codeset($domain, 'UTF-8');
|
bind_textdomain_codeset($domain, 'UTF-8');
|
||||||
textdomain($domain);
|
textdomain($domain);
|
||||||
|
|
||||||
assert(gettext('示例') === 'Example');
|
assert(gettext(json_decode('"\u793a\u4f8b"', true)) === 'Example');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user