dongruoqiong9017 2013-02-18 16:04
浏览 732
已采纳

如何在MacOS X上安装gettext

How do I install gettext on mac?

I get this error on one of my php pages:

Fatal error: Call to undefined function bindtextdomain()

and it's because I don't have gettext installed.

I can't find good instructions on how to install it. I've tried using:

brew install gettext

and it puts some files here:

/usr/local/Cellar/gettext/0.18.2

but I don't know what to do with that.

Update: Instead of trying to use homebrew, now I tried this method unsucessfully using wget:

Download with wget

cd ~/Downloads
wget http://ftp.gnu.org/gnu/gettext/gettext-0.18.2.tar.gz
tar -zxvf gettext-0.18.2.tar.gz
cd gettext-0.18.2
./configure
make

make check is optional to run self-tests

make check

Errors I got:

make[3]: *** [check-TESTS] Error 1

make[2]: *** [check-am] Error 2

make[1]: *** [check-recursive] Error 1

sudo make install

That installs it here: /usr/local/share/gettext

And the documentation here: /usr/local/share/doc/gettext

but how do I make my php pages be able to use gettext and the bindtextdomain() function?

  • 写回答

4条回答 默认 最新

  • dpfz27768 2013-02-23 03:38
    关注

    I finally got it. You have to reconfigure php, so I ended up upgrading from 5.3.15 to 5.4.12. These websites were very helpful:

    http://mac.tutsplus.com/tutorials/server/upgrading-the-native-php-installation-on-os-x-mountain-lion/

    http://mansion.im/2011/php-with-intl-and-gettext-on-osx-lion/

    #Install dependencies
    brew install libjpeg
    brew install pcre
    brew install libxml2
    brew install mcrypt
    
    #Get autoconf just because
    brew install autoconf
    
    #Install Intl extension
    #Install ICU
    #Download from http://site.icu-project.org/download/48#ICU4C-Download
    cd ~/Downloads
    tar xzvf icu4c-4_8_1-src.tgz
    cd icu/source
    ./runConfigureICU MacOSX
    make
    sudo make install
    
    cd ~/Downloads/php-5.4.12/ext/intl
    phpize
    ./configure --enable-intl
    make
    sudo cp modules/intl.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
    
    #Install gettext
    #Download from http://ftp.gnu.org/gnu/gettext/
    cd ~/Downloads
    tar xzvf gettext-0.18.1.1.tar.gz
    cd gettext-0.18.1.1
    ./configure
    make
    sudo make install
    
    cd ~/Downloads/php-5.4.12/ext/gettext
    phpize
    ./configure 
    make
    sudo cp modules/gettext.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
    
    #Add intl and get text to php.ini
    cd ~/Downloads/php-5.4.12
    nano php.ini-development
    #Add these lines
    extension=intl.so
    extension=gettext.so
    
    #Download PHP source files from php.net
    cd ~/Downloads
    tar xzvf php-5.4.12.tar.bz2
    cd php-5.4.12
    
    ./configure \
    --prefix=/usr \
    --with-gettext \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info \
    --sysconfdir=/private/etc \
    --with-apxs2=/usr/sbin/apxs \
    --enable-cli \
    --with-config-file-path=/etc \
    --with-libxml-dir=/usr \
    --with-openssl=/usr \
    --with-kerberos=/usr \
    --with-zlib=/usr \
    --enable-bcmath \
    --with-bz2=/usr \
    --enable-calendar \
    --with-curl=/usr \
    --enable-dba \
    --enable-exif \
    --enable-ftp \
    --with-gd \
    --enable-gd-native-ttf \
    --with-icu-dir=/usr \
    --with-iodbc=/usr \
    --with-ldap=/usr \
    --with-ldap-sasl=/usr \
    --with-libedit=/usr \
    --enable-mbstring \
    --enable-mbregex \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --without-pear \
    --with-pdo-mysql=mysqlnd \
    --with-mysql-sock=/var/mysql/mysql.sock \
    --with-readline=/usr \
    --enable-shmop \
    --with-snmp=/usr \
    --enable-soap \
    --enable-sockets \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --with-tidy \
    --enable-wddx \
    --with-xmlrpc \
    --with-iconv-dir=/usr \
    --with-xsl=/usr \
    --enable-zip \
    --with-imap=/usr/local/imap-2007 \
    --with-kerberos \
    --with-imap-ssl \
    --enable-intl \
    --with-pcre-regex \
    --with-pgsql=/usr \
    --with-pdo-pgsql=/usr \
    --with-freetype-dir=/usr/X11 \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr/X11
    
    make test
    sudo make install
    
    #Restart Apache
    sudo apachectl restart
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3