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 兩個輔助方法
相關文章
相關標籤/搜索