[英]How to use gettext on linux in php?
I've follow instructions from How to load language with gettext in PHP? 我遵循了如何在PHP中使用gettext加载语言的说明?
I've created ./locale/pl_PL/LC_MESSAGES/default.po file with: 我使用以下方法创建了./locale/pl_PL/LC_MESSAGES/default.po文件:
msgid "categories"
msgstr "kategorie"
I've generated mo file using: 我已经使用以下方式生成了mo文件:
msgfmt default.po -o default.mo
and I have code like this: 我有这样的代码:
$lang = 'pl_PL';
$this->root = __DIR__ . DIRECTORY_SEPARATOR;
echo $lang . "\n" . $this->root . "locale\n";
putenv("LC_ALL=$lang");
setlocale(LC_ALL, $lang);
bindtextdomain("default", $this->root . "locale");
textdomain("default");
echo _("categories");
but I've got untranslated text, the output is: 但我有未翻译的文本,输出为:
pl_PL
/home/kuba/projects/jcubic/cataloger/locale
categories
I've also tried to use slash at the end of locale but that didn't help. 我也尝试在语言环境的末尾使用斜杠,但这无济于事。
What's wrong? 怎么了? How can I use gettext to translate text?
如何使用gettext翻译文本? I'm running php from apache 2 on GNU/Linux.
我正在GNU / Linux上从Apache 2运行php。 I'm using slim and twig frameworks.
我正在使用苗条和树枝框架。
我需要将.utf8
添加到语言环境(所以它是pl_PL.utf8
)并且可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.