語(yǔ)言包解決方案(中英文為例,其他可自行添加)
1、復(fù)制gb語(yǔ)言包,放入目錄:e/data/language/中,重命名為:”zh”;
另加入語(yǔ)言包(除gb語(yǔ)言包以外):針對(duì)模板的中文進(jìn)行的語(yǔ)言包制作
命名為:template.php
數(shù)組名為:template_r 將開發(fā)中所有前臺(tái)顯示的語(yǔ)言加入其中作為數(shù)組元素,其數(shù)組元素與其他語(yǔ)言文件數(shù)組元素格式一致
如添加其他語(yǔ)言文件名與”zh”文件夾中一致(enews.php、fun.php、message.php、q_message.php、template.php五個(gè)文件),紅色必須包含,否則錯(cuò)誤!
2. 制作語(yǔ)言包啟動(dòng)切換功能
在全局公共模板變量header中添加(可自定義位置):
function setlang(lang) { document.cookie = "WZ_lang="+lang; }
<input onclick="setlang('en')" type="button" value="English" /> <input onclick="setlang('zh')" type="button" value="中文" />
3. 制作調(diào)用語(yǔ)言包公用頭部信息
命名為:[!---temp.language--]
內(nèi)容如下:
<!--code.start-->?php$lang = $_COOKIE[WZ_lang] //調(diào)取語(yǔ)言?($_COOKIE[WZ_lang].'/'):'zh/'; $WZ_dir = count(explode('/',$_SERVER[PHP_SELF]))-2;$WZ_lang_url_str ='';for($WZ_i=0;$WZ_i<$WZ_dir;$WZ_i++){ //取得相對(duì)路徑$WZ_lang_url_str .= '../'; }@include_once($WZ_lang_url_str.'e/data/language/'.$lang.'pub/fun.php');//載入語(yǔ)言包@include_once($WZ_lang_url_str.'e/data/language/'.$lang.'pub/q_message.php');@include_once($WZ_lang_url_str.'e/data/language/'.$lang.'pub/template.php');?<!--code.end-->
4. 修改gb語(yǔ)言包中的fun.php和q_message.php,以e/data/language/gb/pub/fun.php文件為例!
只修改前臺(tái)用到的數(shù)組元素,后臺(tái)務(wù)做任何修改!
修改方法:'鍵名'=>'',
修改實(shí)例:
找到:
'pripage'=>'上一頁(yè)',
修改為:
'pripage'=>'',
5. template.php的操作方法
針對(duì)出現(xiàn)漢字的模板進(jìn)行修改,以默認(rèn)新聞列表模板為例:
模板中出現(xiàn)”您當(dāng)前的位置:”
將漢字修改為:
<!--code.start-->?php echo $template_r[' here'];?<!--code.end-->
在template.php中添加元素
'here'=>'您當(dāng)前的位置:',(zh語(yǔ)言包)
'here'=>'You are here:',(en語(yǔ)言包)
其他語(yǔ)言包都以此方法添加對(duì)應(yīng)語(yǔ)言
Copyright © 2009-2019 Ywcms.Com All Right Reserved. 湘ICP備16006489號(hào)-2