我试过了
我的翻译文件(* .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/gettext.ini
extension=gettext.so
apache2 restart给了我这个错误:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gettext.so' - /usr/lib/php5/20090626/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0
我做错了什么?据我所知,这是在Linux下安装扩展的标准方法。这在我的本地系统上运行良好,但在亚马逊实例上却没有。
php --version PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gettext.so' - /usr/lib/php5/20090626/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP 5.3.10-1ubuntu3.10 with Suhosin-Patch (cli) (built: Feb 28 2014 23:14:25) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
请指导我在ubuntu上设置此扩展程序。
因此,这个谜团通过出色的SOQ得以解决
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...
通过执行以下步骤,我的问题得以完全解决:
mv da_DK da_DK.utf8(重命名为语言环境目录) bind_textdomain_codeset('messages', 'UTF8');
对我来说,调试点之一是setlocale(LC_ALL, 'da_DK.utf8');
针对无效/不存在的语言环境返回false
那么gettext.so扩展名呢:
我通过apt-get获得的php安装似乎在编译过程中添加了扩展名。我们可以看到gettext是否为已编译模块,例如php -m |grep gettext
,这似乎是真的!我不需要gettext.ini,只有在编译PHP时才需要,--with-gettext=shared
在这里不是这种情况。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句