2008年2月1日 星期五

簡繁php轉換!

//原來的source來自神奇傑利網
//安裝方法:
1.將big5.map、gb.map、ccharset.php置於nuke根目錄下

2.編輯header.php 找到 echo <html> <head>這一行,在其上加入一行ob_start();
即:
ob_start();
echo <html><head>

3.編輯footer.php在最後的foot();之後,加入這一段
global $c_lang;
$RealOutput = ob_get_contents();
ob_end_clean();
if ($c_lang==GB) {
$code=new CCharset;
$RealOutput=$code->Big5_Gb($RealOutput);
}
echo $RealOutput;

4.編輯mainfile.php,在檔頭include(config.php); 這行之下加入這段
if (isset($c_lang)) {
setcookie(clang,$c_lang,time()+3600);
} else {
$c_lang=$HTTP_COOKIE_VARS[clang];
}
include(ccharset.php);

5.底下這段javascript要謹慎使用了,這是簡繁轉換的超連結,要跳離php回到html
而且,看你的選單在那裏而定,也雩茤韘bthemes/.../theme.php 的themeheader()函數裏

?>
<script type=text/javascript>
var where,i;
where=window.location.href;
i=where.lastIndexOf(c_lang);
if (i>0) where=where.substring(0,i-1);
if (where.lastIndexOf(?)>0){
document.write( <a href=+where+&c_lang=GB+>簡體 </a> );
document.write( <a href=+where+&c_lang=big5+> 繁體 </a>);
} else {
document.write( <a href=+where+?c_lang=GB+>簡體 </a> );
document.write( <a href=+where+?c_lang=big5+>繁體 </a>);
}
</script>
<?

6.完工........

【下列文章您可能也有興趣】

沒有留言: