在ubuntu下为php设置gettext
我尝试的是:在ubuntu下为php设置gettext,php,apache,ubuntu,gettext,Php,Apache,Ubuntu,Gettext,我尝试的是: sudo apt get安装php gettext sudo-apt-get-install-gettext sudo-apt-get-install区域设置 我的翻译文件(*.mo,*.po)位于/usr/local/php/include/myapp/i18n/locale/下,例如 /usr/local/php/include/myapp/i18n/locale/da_DK/LC_MESSAGES/generic.mo 我已经放置了/etc/php5/conf.d/gette
/usr/local/php/include/myapp/i18n/locale/
下,例如
/usr/local/php/include/myapp/i18n/locale/da_DK/LC_MESSAGES/generic.mo
我已经放置了/etc/php5/conf.d/gettext.ini
extension=gettext.so
apache2重新启动时出现以下错误:
PHP警告:PHP启动:无法加载动态库'/usr/lib/php5/20090626/gettext.so'-/usr/lib/php5/20090626/gettext.so'-/usr/lib/php5/20090626/gettext.so:无法打开共享对象文件:在第0行的未知位置没有此类文件或目录
我做错了什么?据我所知,这是在linux下安装扩展的标准方法。这在我的本地系统上运行良好,但在amazon实例上却不行
php——版本
PHP警告:PHP启动:无法加载动态库'/usr/lib/php5/20090626/gettext.so'-/usr/lib/php5/20090626/gettext.so'-/usr/lib/php5/20090626/gettext.so:无法打开共享对象文件:在第0行的未知位置没有此类文件或目录
PHP 5.3.10-1ubuntu3.10,带有Suhosin修补程序(cli)(构建日期:2014年2月28日23:14:25)
版权所有(c)1997-2012 PHP集团
Zend Engine v2.3.0版权所有(c)1998-2012 Zend Technologies
请指导我在ubuntu上设置这个扩展。所以这个谜团由优秀的 php.net上gettext的一个示例是:
Warning for Linux (Ubuntu) users! Your system will *only* support the locales installed on your OS, in the *exact* format given by your OS. (See also the PHP setlocale man page.) To get a list of them, enter locale -a, which will give you something like this:
C
en_US.utf8
ja_JP.utf8
POSIX
So this machine only has English and Japanese! To add eg. Finnish, install the package:
sudo apt-get install language-pack-fi-base
Rerun locale -a, and "fi_FI.utf8" should appear. Make sure you're using the same name in your PHP code:
setlocale(LC_ALL, "fi_FI.utf8");
Adjust your po paths so that they match, e.g. "./locale/fi_FI.utf8/LC_MESSAGES/messages.po".
Now restart Apache, and it should finally work. Figuring this out took quite a while...
我的问题完全通过以下步骤解决:
bind_textdomain_代码集('messages','UTF8')代码>
我的一个调试点是setlocale(LC_ALL'da_DK.utf8')代码>对于无效/不存在的区域设置返回false
php-m | grep gettext
,这似乎是真的!
我不需要,只有在编译PHP时才需要它,使用gettext=shared,这里不是这种情况。是的,我已经做过了。你可以尝试
定位gettext。因此
看看它是否是在不同的位置构建的。如果是这样,请尝试修改php.ini文件中的指令。是否有理由拒绝投票?另外,您确定/etc/php4
正确吗?您使用的是5.3.x,而不是版本4。我已经跳过了php的命令行--version。它的php5,也就是拼写错误,很抱歉,我遇到了为各种环境设置gettext的问题,即在Ubuntu上和在XAMPP上的Windows上(包括这里的区域设置)。我在我的博客上的一篇文章中记录了所有这些问题,供那些仍在为这些问题挣扎的人参考: