1 changed files with 25 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||
<?php |
|||
require_once __DIR__ . '/vendor/autoload.php'; |
|||
|
|||
use sqhlib\Hanzi\HanziConvert; |
|||
|
|||
class Ctranslate extends HanziConvert{ |
|||
function simpleToTrad($str){ |
|||
return $this->convert($str,true); |
|||
} |
|||
|
|||
function tradToSimple($str){ |
|||
return $this->convert($str,false); |
|||
} |
|||
} |
|||
// $str = '平時已秉班揚筆,暇處不妨甘石經。吾里忻傳日邊信,君言頻中斗杓星。會稽夫子餘詩禮,巴蜀君平舊典型。歷歷周天三百度,更參璿玉到虞廷。'; |
|||
// echo HanziConvert::convert($str);//默认是繁体转简体 |
|||
// echo HanziConvert::convert($str,true);//第二个参数传入布尔真则是简体转繁体 |
|||
|
|||
|
|||
//简体转繁体 |
|||
echo $str = '平时已秉班扬笔,暇处不妨甘石经。吾里忻传日边信,君言频中斗杓星。会稽夫子余诗礼,巴蜀君平旧典型。歷歷周天三百度,更参璇玉到虞廷。'; |
|||
echo "<br/>"; |
|||
|
|||
$ct = new Ctranslate(); |
|||
echo $ct->simpleToTrad($str); |
Loading…
Reference in new issue