ubuntu 无法使用php gettext的问题

今天把一台 php server 迁移服务器,新服务器使用 ubuntu,老的是 centos,在 centos下无问题, 迁移到 ubuntu 之后 php gettext 就是无法使用,表现为无法翻译内容,显示的内容还是老的。

经过检查

php-gettext

gettext

安装都正常

排查之后发现是 ubuntu 默认不支持 zh_CN 语言字符集

这里要说明一下,使用 gettext 是需要依赖系统支持的语言集,如果系统不支持 zh_CN,翻译成这种 语言根本也就无法使用了

给 ubuntu 添加 zh_CN 语言支持

/var/lib/locales/supported.d/local 文件中添加新行,内容如下

zh_CN UTF-8

然后运行 dpkg-reconfigure locales

重启 apache 之后搞定

另外说一下,查看系统支持的语言集命令

locales -a

en_US.UTF-8 UTF-8
zh_CN UTF-8
zh_CN.UTF-8 UTF-8
This entry was posted in Linux, PHP and tagged , , . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>