gpt4 book ai didi

PHP gettext 不起作用

转载 作者:行者123 更新时间:2023-12-04 18:28:38 24 4
gpt4 key购买 nike

Gettext 根本不适合我:

    putenv('LC_ALL=zh_CN.utf8');
setlocale(LC_ALL, 'zh_CN.utf8');
bindtextdomain('messages', __DIR__.'/locale');
textdomain('messages');

messages.mo 位置是 locale/zh_CN.utf8/LC_MESSAGES。
$locale -a
C
en_AG
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
zh_SG.utf8

我在 Ubuntu 上。

任何想法?

最佳答案

判断 this note ,您很可能缺少 UTF-8 位。这些帮助我解决了“Gettext not working”的问题。

$directory = dirname(__FILE__).'/locale';
$domain = 'mydomain';

$locale ="fi_FI.utf8";

//putenv("LANG=".$locale); //not needed for my tests, but people say it's useful for windows

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

在语言环境中,应该有文件结构
./locale/pt/LC_MESSAGES/mydomain.mo

或类似的。

重要提示:如果 Apache 已经读取了 mo 文件,则需要重新启动它才能读取新文件。换句话说,还有一些我还不知道的缓存系统。

关于PHP gettext 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6398927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com