时间:2021-07-01 10:21:17 帮助过:13人阅读
输出“Hi”。但我们是中国人,我们不认识“Hi”,
$domain = 'test';
bindtextdomain($domain, "locale/");//设置某个域的mo文件路径
textdomain($domain);//设置gettext()函数从哪个域去找mo文件
echo gettext("Hi!");//_()是gettext()函数的简写形式
?>
这时你运行改程序,只会
输出“你好”。
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-01-19 17:47+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME\n"
"Language-Team: LANGUAGE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: hi.php:6
msgid "Hi!"
msgstr ""
现在有两个地方需要修改,
1:"Content-Type: text/plain; charset=CHARSET\n"
2:msgstr ""
把1中的CHARSET修改成gb2312,然后把2修改成msgstr "你好"。
3,键入msgfmt -o hi.mo hi.po,执行,这时生成hi.mo文件。
然后在d:\www下新建locale\zh_Cn\LC_MESSAGES目录,把hi.mo拷到这里就行了。
4,现在重启apache,再次运行,屏幕上可以
http://www.bkjia.com/PHPjc/324154.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324154.htmlTechArticle步骤一:搭建环境 1,首先查看你的php扩展目录下是否有php_gettext.dll这个文件,如果没有,这就需要你 下载一个或是从其他地方拷贝一个,...