PHP on Mac OS X Lion: where is gettext module?
Solution 1
EDIT : Just tested and still works on Mavericks as long as you update MAMP with the latest version. Here is the full tutorial :
I managed to make it work using the gettext.so
from MAMP with Mac OS X Apache/PHP native server. Here is how to so it :
- Download and install MAMP (pro not needed)
-
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/
-
Update Mavericks'
/etc/php.ini
file by adding this new line :extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/gettext.so
-
Restart apache :
sudo apachectl restart
After that you can use _()
and gettext()
functions.
Thanks to @MountainAsh for noticing that we can't remove MAMP after this procedure since gettext uses one of MAMP libraries.
Solution 2
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.
Try this as root (or issue sudo -s before):
mkdir -p /SourceCache
cd /SourceCache
curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz
tar xzf gettext-0.17.tar.gz
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
make
make install
cd /SourceCache
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
cd /SourceCache/php-5.3.0/ext/gettext
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
make
make install
When done, edit/create /etc/php.ini and add: extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so
next issue: sudo apachectl graceful
Good luck!
Francesco
Updated on June 04, 2022Comments
-
Francesco almost 2 years
I have a brand new Mac, with Lion preinstalled. I enabled Apache, the PHP module.
phpinfo()
works but there is no support for gettext.Writing
extension=php_gettext.so
in php.ini did not help. So I tried tolocate
it in the filesystem, but it seems there are no PHP extensions available.Where are PHP extensions in OS X Lion?
-
mbritto over 11 yearsAs I told in the answer bellow, you can use the gettext.so from MAMP with Lion/Mountain Lion version of PHP. It's very simple and works like a charm for me
-
MountainAsh almost 10 yearsas of commenting step 3 changes to
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/
and step 5 is not possible (to uninstall) as gettext.so makes a call to/Applications/MAMP/Library/lib/libiconv.2.dylib
on PHP load -
MountainAsh almost 10 yearsFurther to my comments above, you can delete all from MAMP's 800+MB payload and just leave the following files and directory structure:
/Applications/MAMP/Library/lib/libiconv.2.dylib
&/Applications/MAMP/Library/lib/libintl.8.dylib
which takes it down to 1.2 MB -
Admin over 9 yearsFor others dropping by: I've successfully built gettext-0.19.3 on a PowerPC based Mac running 10.5.8. make check fails with 'lang-bash', but apart from that, it installs fine.