php i18n gettext 实现多语言

来源:互联网 发布:vb 资源文件 编辑:程序博客网 时间:2024/05/22 04:33

<?php

header("Content-type: text/html; charset=utf-8");

$lng = $_GET['lng'] ? $_GET['lng'] :'zh_TW';

$domain = 'test';

putenv('LANG='.$lng); 

setlocale(LC_ALL, $lng); // 指定要用的语系,如:en_US、zh_CN、zh_TW 

bindtextdomain($domain, '/home/dfct/test'); 

bind_textdomain_codeset($domain, 'UTF-8'); 

textdomain($domain); 

//($_ENV);

// E:/wwwroot/test/zh_TW/LC_MESSAGES/test.mo 

echo _("中文"); 


E:\wwwroot\test\en_US\LC_MESSAGES\test.mo


生成po 和pot文件用 poedit 比较方便

0 0
原创粉丝点击