To create the .po (write your translations to this file):
cd ..
find *.php common/*.php &line; xargs xgettext -C -o amp.po –keyword=_ -

To create the .mo: 
msgfmt -v amp.po -o amp.mo

以上是说明。

修改获得的PO文件头:

"Content-Type: text/plain; charset=utf-8\\n"
"Content-Transfer-Encoding: 8bit\\n"

结果调用:msgfmt -v amp.po -o amp.mo 出现

invalid multibyte sequence

找了找资料:使用 iconv -t utf-8 ampsf.po

结果报告 illegal input sequence at position 311

再用:iconv -f gb2312 -t utf-8 ampsf.po 这次OK,结果仍然MO出错

再看看,请用 iconv 把你的 po 文件的编码转成 UTF-8 的,也可以用 gedit 保存成 UTF-8 的编码。
只有用 UTF-8,msgfmt 才能编译你的 po 文件

索性用EDITPLUS另存为UTF-8格式,再FTP上传,最后搞定。

<?php
 setlocale(LC_MESSAGES, \’zh_CN\’);
 bindtextdomain(\’ampsf\’,\’./i18n\’);
 textdomain(\’ampsf\’);
?>

php 中文手册
字符串处理函数库
setlocale
配置地域化信息。
语法: string setlocale(string category, string locale);
返回值: 字符串
函数种类: 操作系统与环境
内容说明
本函数用来配置地域的信息。参数 category 有下列的选择:
LC_ALL 包括下面的全项选项都要。
LC_COLLATE 配置字符串比较,PHP 目前尚未实作出来本项。
LC_CTYPE 配置字符类别及转换。例如全变大写 strtoupper()。
LC_MONETARY 配置金融货币,PHP 目前尚未实作。
LC_NUMERIC 配置小数点后的位数。
LC_TIME 配置时间日期格式,与 strftime() 合用。
而参数 locate 若是空字符串 "",则会使用系统环境变量的 locate 或是 LANG 的值。若 locate 为零,则不会改变地域化配置。返回新的地域,若系统尚未实作则返回 false。
 

bindtextdomain
(PHP 3 >= 3.0.7, PHP 4, PHP 5)
bindtextdomain — Sets the path for a domain
Description
string bindtextdomain ( string domain, string directory )
The bindtextdomain() function sets the path for a domain. It returns the full pathname for the domain currently being set.

 
textdomain
(PHP 3 >= 3.0.7, PHP 4, PHP 5)
textdomain — Sets the default domain
说明
string textdomain ( string text_domain )
This function sets the domain to search within when calls are made to gettext(), usually the named after an application.
参数
text_domain
The new message domain, or NULL to get the current setting without changing it

历史博文

标签:
八月 19, 2005 at 2:43 下午 by yippee 1,038 次
Category: Dev
Tags: