Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ubuntu下为php设置gettext_Php_Apache_Ubuntu_Gettext - Fatal编程技术网

在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

我尝试的是:

  • 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/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...
    
    我的问题完全通过以下步骤解决:

  • sudo apt get安装语言包da base(丹麦语)
  • 区域设置-a(已确认已加载da_DK区域设置)
  • mv da_DK da_DK.utf8(重命名为locales dir)
    bind_textdomain_代码集('messages','UTF8')

    我的一个调试点是
    setlocale(LC_ALL'da_DK.utf8')对于无效/不存在的区域设置返回false

  • 那么gettext.so扩展呢:

    我通过apt-get安装的php似乎在编译过程中添加了扩展 我们可以看到gettext是否是编译模块,例如
    php-m | grep gettext
    ,这似乎是真的!
    我不需要,只有在编译PHP时才需要它,使用gettext=shared
    ,这里不是这种情况。

    是的,我已经做过了。你可以尝试
    定位gettext。因此
    看看它是否是在不同的位置构建的。如果是这样,请尝试修改php.ini文件中的指令。是否有理由拒绝投票?另外,您确定
    /etc/php4
    正确吗?您使用的是5.3.x,而不是版本4。我已经跳过了php的命令行--version。它的php5,也就是拼写错误,很抱歉,我遇到了为各种环境设置gettext的问题,即在Ubuntu上和在XAMPP上的Windows上(包括这里的区域设置)。我在我的博客上的一篇文章中记录了所有这些问题,供那些仍在为这些问题挣扎的人参考: