1
This commit is contained in:
@@ -48,7 +48,7 @@ class TranslationJob
|
|||||||
}
|
}
|
||||||
|
|
||||||
$languages = ['cn' => 'cn', 'en' => 'en', 'ru' => 'ru', 'ar' => 'ar'];
|
$languages = ['cn' => 'cn', 'en' => 'en', 'ru' => 'ru', 'ar' => 'ar'];
|
||||||
$languages = array_merge(['to'=>$toLang],$languages);
|
// $languages = array_merge(['to'=>$toLang],$languages);
|
||||||
unset($languages[$sourceLang]);
|
unset($languages[$sourceLang]);
|
||||||
log::info('languages', [$languages]);
|
log::info('languages', [$languages]);
|
||||||
foreach ($languages as $lang => $xflang) {
|
foreach ($languages as $lang => $xflang) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class TranslatorService
|
|||||||
$rst_dst = $this->xunfei->fanyi($var, $fromLang, $targetLang);
|
$rst_dst = $this->xunfei->fanyi($var, $fromLang, $targetLang);
|
||||||
if ($rst_dst) {
|
if ($rst_dst) {
|
||||||
$vehicle[$k] = $rst_dst["trans_result"]["dst"];
|
$vehicle[$k] = $rst_dst["trans_result"]["dst"];
|
||||||
|
}else{
|
||||||
|
unset($vehicle[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -53,8 +53,8 @@ class Xunfei
|
|||||||
//在控制台-我的应用-机器翻译获取
|
//在控制台-我的应用-机器翻译获取
|
||||||
$api_key = "b6d805f240176ecaea85130cb5f2bca1";
|
$api_key = "b6d805f240176ecaea85130cb5f2bca1";
|
||||||
// 机器翻译接口地址
|
// 机器翻译接口地址
|
||||||
// $url = "https://ntrans.xfyun.cn/v2/ots";
|
$url = "https://ntrans.xfyun.cn/v2/ots";
|
||||||
$url = "http://ntrans.example.cn";
|
// $url = "http://ntrans.example.cn";
|
||||||
//body组装
|
//body组装
|
||||||
// $text = "中华人民共和国于1949年成立";//待翻译文本
|
// $text = "中华人民共和国于1949年成立";//待翻译文本
|
||||||
$body = json_encode($this->getBody($app_id, $from, $to, $text));
|
$body = json_encode($this->getBody($app_id, $from, $to, $text));
|
||||||
|
|||||||
Reference in New Issue
Block a user