首页 Soft PlugIn RAN乱 Dev开发 Info资料 English WAP 留言 登陆 注册
-
Posted by Yippee | 评论(0) | 引用(0) | 阅读2248次
php本地化国际化

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


字体:

Permanant URI永久地址 http://www.shengfang.org/blog/p/phpi18n.php
Trackback URI引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1124433801

2005年8月19日14:43星期五  [Dev开发] 追踪此文的RSS
提示:
此文还没有评论。

称呼:    登陆   注册
   不注册,但记住我的信息
邮件:
(非必须)
评论: [UBB代码帮助]
粗体 斜体 下划线 链接 水平线 引用



验证码: 请输入你看见的数字
关闭UBB      提交时自动将内容复制到剪贴板

公告
Fire and Motion!

统计信息
[Yippee]||[统计]||日志:1790
在线: 23||用户: 2562 [列表]
今日:2175||到访:2671674
Rss:838448||评论:1584

最新日志

最新评论

友情链接

日历

最新引用

搜索

归档

杂项
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
编码:  UTF-8