本人对php所知不多,即使偶尔修改些php的网页也是摸索着查资料来实现,望php行家莫见笑。
这个方案的特点就是使用简单,只要在需要调用转换函数的页面加入include_once'language.inc',就可以方便使用函数了。
关于使用方法就附上我当初转语言插件的代码:
<?
php
function dirtree( $path = " . " )
{
include_once ' language.inc ' ;
$d = dir ( $path );
while ( false !== ( $v = $d -> read()))
{
if ( $v == " . " || $v == " .. " )
continue ;
$file = $d -> path . " / " . $v ;
if ( is_dir ( $file ))
{
// echo "$v";
dirtree( $file );
}
else
echo $file . " \n " ;
// rename($file,str_replace('zh_tw','zh_cn',$file));
//$filename='zh_cn.lang.php';
$fd = fopen ( $file , ' r ' );
$contents = fread ( $fd , filesize ( $file ));
$contents = u2b( $contents );
$contents = b2g( $contents );
// echo $contents;
$contents = str_replace ( ' 日 ' , ' 日历 ' , $contents );
$contents = g2u( $contents );
$contents = str_replace ( ' Trade chinese language pack created by METO, Inc. http://www.meto.com.tw ' , ' Simple chinese language pack created by Steed Soft Technology, Inc. http://www.steedsoft.com ' , $contents );
fclose ( $fd );
$fd = fopen ( str_replace ( ' zh_tw/ ' , ' zh_cn/ ' , str_replace ( ' zh_tw ' , ' zh_cn ' , $file )) , ' w ' );
fwrite ( $fd , $contents );
fclose ( $fd );
// rename($file,str_replace('zh_tw','zh_cn',$file));
}
$d -> close();
// echo " ";
}
dirtree( " zh_tw " );
?>
function dirtree( $path = " . " )
{
include_once ' language.inc ' ;
$d = dir ( $path );
while ( false !== ( $v = $d -> read()))
{
if ( $v == " . " || $v == " .. " )
continue ;
$file = $d -> path . " / " . $v ;
if ( is_dir ( $file ))
{
// echo "$v";
dirtree( $file );
}
else
echo $file . " \n " ;
// rename($file,str_replace('zh_tw','zh_cn',$file));
//$filename='zh_cn.lang.php';
$fd = fopen ( $file , ' r ' );
$contents = fread ( $fd , filesize ( $file ));
$contents = u2b( $contents );
$contents = b2g( $contents );
// echo $contents;
$contents = str_replace ( ' 日 ' , ' 日历 ' , $contents );
$contents = g2u( $contents );
$contents = str_replace ( ' Trade chinese language pack created by METO, Inc. http://www.meto.com.tw ' , ' Simple chinese language pack created by Steed Soft Technology, Inc. http://www.steedsoft.com ' , $contents );
fclose ( $fd );
$fd = fopen ( str_replace ( ' zh_tw/ ' , ' zh_cn/ ' , str_replace ( ' zh_tw ' , ' zh_cn ' , $file )) , ' w ' );
fwrite ( $fd , $contents );
fclose ( $fd );
// rename($file,str_replace('zh_tw','zh_cn',$file));
}
$d -> close();
// echo " ";
}
dirtree( " zh_tw " );
?>
下载地址
也可以登陆该网页下载:http://www.layman.5gigs.com/download/(还要些别的好东西等着你)
P.S
该方案的缺点,因为繁体中文和简体中文存在一定的词法不一致的情况,因此会发现有些词无法转换,我从网上找到了两个处理该问题的dat文件,但具体实现我没有做,以后也许会抽时间研究下并做个更新。