php gettext 注释

//setlocale(LC_ALL, "en_US.UTF-8");
setlocale(LC_ALL, "zh_CN.UTF-8");
bindtextdomain("module1", "//path/to/my/locale/folder"); #添加语言文件
bindtextdomain("module2", "//path/to/my/locale/folder");#添加语言文件
bind_textdomain_codeset("module1" , 'UTF-8' );#设置语言文件编码
textdomain("module1");#设置默认取语言的的文件
echo _("Label1"); // gettext("Label1"); 取语言Label1
echo dgettext("module2", "Label1"); // 往 module2 语言文件取语言
//默认取 //path/to/my/locale/folder/zh_CN/LC_MESSAGES/module1.mo
//往不在LC_MESSAGES 取语言使用以下方法
echo dcgettext ( "module2", "Label1" , LC_MESSAGES);
//category 可选值
# LC_ALL 所有的设置
# LC_COLLATE 字符串比较, 详见 strcoll()
# LC_CTYPE 字符串的分类与转换, 参见例子 strtoupper()
# LC_MONETARY 等同 localeconv()
# LC_NUMERIC 对于小数点的分隔 (另请参见 localeconv())
# LC_TIME 时间与格式 strftime()
# LC_MESSAGES 系统响应 (如果PHP使用libintl编译)


#语言复数问题 英文复数 转为其他语言
#参数: 单数 复数 数量
//echo ngettext("File", "Files", $number);
#根据$number来返回指定的语言,还有dngettext dcngettext 两个辅助方法

  

posted @ 2016-03-18 20:46  liushan  阅读(456)  评论(0编辑  收藏  举报