php页面如下<?php
//定义要翻译的目标语言及po文件的编码
$locale = "en";
setlocale(LC_ALL, $locale);
 
//设置翻译文本域,下面的代码就会让程序去locale/en/LC_MESSAGES/default.mo去寻找翻译文件
bindtextdomain("default", dirname(__FILE__)."/locale");
textdomain("default");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title><?php echo _('Title'); ?></title>
</head>
<body>
<?php echo _("Hello")."<br>"; ?>
<?php echo _("Title"); ?>
</body>
</html>default.op文件如下msgid ""
msgstr ""
"Project-Id-Version: v1.0\n"
"POT-Creation-Date: 2012-02-08 16:07+0800\n"
"PO-Revision-Date: 2012-02-08 16:10+0800\n"
"Last-Translator: illhan98 <[email protected]>\n"
"Language-Team: illhan98 <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
"X-Poedit-Language: English\n"
"X-Poedit-Country: UNITED STATES\n"
"X-Poedit-SourceCharset: utf-8\n"msgid "Title"
msgstr "buyaotaichangle"msgid "Hello"
msgstr "Hello Word!!!"编译成mo文件以后,php页面没有显示Hello Word!!!的字样,
locale文件夹下面是有default.mo文件的locale/en/LC_MESSAGES/default.mo