You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
719 B
37 lines
719 B
<?php
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
use sqhlib\Hanzi\HanziConvert;
|
|
|
|
class Ctranslate extends HanziConvert
|
|
{
|
|
|
|
function fix($str){
|
|
$arr = array(
|
|
'槼' => '規',
|
|
'讅' => '審',
|
|
);
|
|
foreach($arr as $k => $v){
|
|
$str = str_replace($k, $v, $str);
|
|
}
|
|
return $str;
|
|
}
|
|
|
|
function simpleToTrad($str)
|
|
{
|
|
$str = $this->convert($str, true);
|
|
$str = $this->fix($str);
|
|
return $str;
|
|
}
|
|
|
|
function tradToSimple($str)
|
|
{
|
|
return $this->convert($str, false);
|
|
}
|
|
}
|
|
|
|
// 简体转繁体
|
|
// echo $str = '价格审查';
|
|
// echo "<br/>";
|
|
// $ct = new Ctranslate();
|
|
// echo $ct->simpleToTrad($str);
|
|
|