macos Mac OS X Lion 上的 PHP:gettext 模块在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7447463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:25:58  来源:igfitidea点击:

PHP on Mac OS X Lion: where is gettext module?

phpmacosgettextosx-lion

提问by Francesco

I have a brand new Mac, with Lion preinstalled. I enabled Apache, the PHP module.

我有一台全新的 Mac,预装了 Lion。我启用了 Apache,即 PHP 模块。

phpinfo()works but there is no support for gettext.

phpinfo()有效,但不支持 gettext。

Writing extension=php_gettext.soin php.ini did not help. So I tried to locateit in the filesystem, but it seems there are no PHP extensions available.

extension=php_gettext.so在 php.ini 中编写没有帮助。所以我locate在文件系统中尝试过,但似乎没有可用的 PHP 扩展。

Where are PHP extensions in OS X Lion?

OS X Lion 中的 PHP 扩展在哪里?

回答by mbritto

EDIT : Just tested and still works on Mavericksas long as you update MAMP with the latest version. Here is the full tutorial :

编辑:只要您使用最新版本更新MAMP,刚刚测试过并且仍然适用于 Mavericks。这是完整的教程:

I managed to make it work using the gettext.sofrom MAMPwith Mac OS X Apache/PHP native server. Here is how to so it :

我设法使用gettext.sofrom MAMP和 Mac OS X Apache/PHP 本机服务器使其工作。这是如何做到的:

  1. Download and install MAMP (pro not needed)
  2. Copy the MAMP gettext.so built for php 5.5.10 to Mavericks' local php extensions folder:

    sudo cp /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20100525/gettext.so /usr/lib/php/extensions/no-debug-non-zts-20100525/

  3. Update Mavericks' /etc/php.inifile by adding this new line :

    extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/gettext.so

  4. Restart apache :

    sudo apachectl restart

  1. 下载并安装 MAMP(不需要专业版)
  2. 将为 php 5.5.10 构建的 MAMP gettext.so 复制到 Mavericks 的本地 php 扩展文件夹:

    sudo cp /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20100525/gettext.so /usr/lib/php/extensions/no-debug-non-zts-20100525/

  3. /etc/php.ini通过添加以下新行来更新 Mavericks 的文件:

    extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/gettext.so

  4. 重启阿帕奇:

    sudo apachectl restart

After that you can use _()and gettext()functions.

之后就可以使用_()gettext()运行了。

Thanks to @MountainAsh for noticing that we can't remove MAMP after this procedure since gettext uses one of MAMP libraries.

感谢@MountainAsh 注意到我们无法在此过程后删除 MAMP,因为 gettext 使用 MAMP 库之一。

回答by T1000

OS X so far does not include gettext (since my first attempt from 10.4). You'll have to build it yourself. I followed the process below and worked under 10.6 (taken from an Apple forum discussion thread). It's still working now in 10.7. Note that this is to install gettext module, not php_gettext. Though they function pretty much the some way, initialization supposedly is different. Remember though to swap the link for the right PHP version. I think 10.7 comes with PHP 5.3.6. You'll need to search for it.

到目前为止,OS X 不包括 gettext(因为我从 10.4 开始第一次尝试)。你必须自己构建它。我遵循以下流程并在 10.6 下工作(取自 Apple 论坛讨论主题)。它现在仍在 10.7 中工作。请注意,这是安装 gettext 模块,而不是 php_gettext。尽管它们的功能差不多,但初始化应该是不同的。请记住,将链接交换为正确的 PHP 版本。我认为 10.7 随 PHP 5.3.6 一起提供。你需要搜索它。

Try this as root (or issue sudo -s before):

以 root 身份尝试(或之前发出 sudo -s ):



mkdir -p /SourceCache

mkdir -p /SourceCache

cd /SourceCache

cd /源缓存

curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz

curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz

tar xzf gettext-0.17.tar.gz

tar xzf gettext-0.17.tar.gz

cd gettext-0.17

cd gettext-0.17

MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure

MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure

make

制作

make install

进行安装



cd /SourceCache

cd /源缓存

curl -O http://www.opensource.apple.com/source/apachemod_php/apache_modphp-53/php-5.3.0.tar.bz2

curl -O http://www.opensource.apple.com/source/apachemod_php/apache_modphp-53/php-5.3.0.tar.bz2

tar xjf php-5.3.0.tar.bz2

焦油 xjf php-5.3.0.tar.bz2

cd /SourceCache/php-5.3.0/ext/gettext

cd /SourceCache/php-5.3.0/ext/gettext

phpize

phpize

MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure

MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure

make

制作

make install

进行安装



When done, edit/create /etc/php.ini and add: extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so

完成后,编辑/创建 /etc/php.ini 并添加:extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so

next issue: sudo apachectl graceful

下一期:sudo apachectl 优雅

Good luck!

祝你好运!

回答by Macmade

/usr/lib/php/extensions/

You will find them here...

你会在这里找到它们......

gettext does not seem to be included in Lion's version of PHP.

gettext 似乎没有包含在 Lion 的 PHP 版本中。

回答by Thomas Tempelmann

For me, re-installing the current PHP version (5.5.29 on OS X 10.10.5 Yosemite) from http://php-osx.liip.chwas the easiest solution - no need to build my own gettext.so extension any more.

对我来说,从http://php-osx.liip.ch重新安装当前的 PHP 版本(OS X 10.10.5 Yosemite 上的 5.5.29)是最简单的解决方案 - 无需构建我自己的 gettext.so 扩展任何更多的。