获取文本: ubuntu? (但不在本地主机上)

发布于 2024-12-22 09:18:54 字数 2190 浏览 2 评论 0原文

现在需要花费数周的时间来尝试使其工作,但在 Ubuntu 上却行不通。 (即使它可以在本地主机上运行...)

这是选择语言的 PHP 代码。此代码位于以下路径中: /srv/d_disk/www/www.domaine.com/htdocs/www/mainsite/index.php

putenv("LANG=$langage");
$directory = dirname(__FILE__).'/locale';

$domain = 'traductions';
$locale=$langage . '.utf8';

setlocale( LC_MESSAGES, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');

变量 $langage 由以下任一者填充: fr_FR 或 en_US (我做了 echo 和它更改正确)但屏幕上的语言没有更改。

locale -a 显示区域设置 fr_FR.utf8 和 fr_FR 已安装(en_US 相同) .po 和 .mo 可以在这里找到: /srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR.utf8/LC_MESSAGES

我用以下命令重新编译了 .po 文件: msgfmt -o traductions.mo -v traductions.po

.po 文件如下:

msgid ""
msgstr ""
"Project-Id-Version: test\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-17 19:41+0100\n"
"PO-Revision-Date: 2011-11-22 20:45+0100\n"
"Last-Translator: \n"  
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;{t}\n"
"X-Poedit-Basepath: ../../../mainsite/presentation/templates\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0:    /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates\n"
"X-Poedit-SearchPath-1: ../../../mainsite/presentation/templates\n"

#: /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates/about-us.c:1
msgid "About Us"
msgstr "A Propos de Nous"

但没有任何改变...

在 phpinfo 中,我有启用 GETTEXT 支持的标签。

一个想法?

编辑:通过使用 strace 我得到以下 =>

PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php5/20090626+lfs/gettext.so' - /usr/lib/php5/20090626+lfs/gettext.so: 
cannot open shared object file: No such file or directory in Unknown on line 0
Bienvenue<br />Bonne journ?e<br />   

编辑2:通过删除 gettext.so,我在使用 strace 时有以下内容: strace -e trace=文件 -o test.txt php test_hasher.php 欢迎
祝您愉快?e


这意味着它在 strace 中被翻译成法语,但在重新加载页面时则不会(即使在缓存清理和重新启动 apache 之后)

It will now make many weeks it try to make it work but it doesn't on Ubuntu.
(even though it works on localhost...)

Here is the PHP code where the selection of the language is made. This code is in the following path : /srv/d_disk/www/www.domaine.com/htdocs/www/mainsite/index.php

putenv("LANG=$langage");
$directory = dirname(__FILE__).'/locale';

$domain = 'traductions';
$locale=$langage . '.utf8';

setlocale( LC_MESSAGES, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');

The variable $langage is filled in by either : fr_FR, or en_US (i did an echo and it changed correctly) but language doesn't change on screen.

the locale -a gives shows me that the locale fr_FR.utf8 and fr_FR are installed (same for en_US)
the .po and .mo can be found here :
/srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR.utf8/LC_MESSAGES

i recompiled the .po files with :
msgfmt -o traductions.mo -v traductions.po

the .po file is the following :

msgid ""
msgstr ""
"Project-Id-Version: test\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-17 19:41+0100\n"
"PO-Revision-Date: 2011-11-22 20:45+0100\n"
"Last-Translator: \n"  
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;{t}\n"
"X-Poedit-Basepath: ../../../mainsite/presentation/templates\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0:    /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates\n"
"X-Poedit-SearchPath-1: ../../../mainsite/presentation/templates\n"

#: /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates/about-us.c:1
msgid "About Us"
msgstr "A Propos de Nous"

but nothing changed...

In phpinfo, i have the label that GETTEXT support is enabled.

An idea ?

EDIT : By using strace i get the following =>

PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php5/20090626+lfs/gettext.so' - /usr/lib/php5/20090626+lfs/gettext.so: 
cannot open shared object file: No such file or directory in Unknown on line 0
Bienvenue<br />Bonne journ?e<br />   

EDIT 2 : By removing the gettext.so, i have the following when using strace :
strace -e trace=file -o test.txt php test_hasher.php
Bienvenue
Bonne journ?e

Which means it's translated in French in strace but NOT when recharhing the page (even after cache cleanup and restart of apache)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2024-12-29 09:18:54

如果将区域设置目录更改为 /srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR/LC_MESSAGES 会发生什么?即删除“.utf8”

What happens if you change the locale dir to /srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR/LC_MESSAGES ? i.e. removing the ".utf8"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文