日期:2014-05-17 浏览次数:20606 次
第一步:撰写PHP程序
<?php
putenv("LANG=zh_CN");
setlocale(LC_ALL, "zh_CN");
bindtextdomain("test", "./locale");
textdomain("test");
echo gettext("Hello!");
echo gettext("World!");
echo gettext("Hello World!");
?>
第二步:
xgettext.exe -d test -L PHP --from-code=utf-8 index.php
第三步:
修改test.po为:
#: ../index.php:8
msgid "Hello!"
msgstr "你好!"
#: ../index.php:9
msgid "World!"
msgstr "世界!"
#: ../index.php:10
msgid "Hello World!"
msgstr "你好,世界!"
第四步:
msgfmt -o zh_CN/test.mo zh_CN/test.po
生成test.mo文件
第五步:
创建locale\zh_CN\LC_MESSAGES目录,将test.mo放入该目录中
第六步:
重启apache,访问index.php即可看到效果
------解决方案--------------------
编码用utf-8试试