diff --git a/app/queue/jobs/TranslationJob.php b/app/queue/jobs/TranslationJob.php index f3aca0a..ed052d8 100644 --- a/app/queue/jobs/TranslationJob.php +++ b/app/queue/jobs/TranslationJob.php @@ -48,7 +48,7 @@ class TranslationJob } $languages = ['cn' => 'cn', 'en' => 'en', 'ru' => 'ru', 'ar' => 'ar']; - $languages = array_merge(['to'=>$toLang],$languages); +// $languages = array_merge(['to'=>$toLang],$languages); unset($languages[$sourceLang]); log::info('languages', [$languages]); foreach ($languages as $lang => $xflang) { diff --git a/app/service/TranslatorService.php b/app/service/TranslatorService.php index c9802f5..a4ed8e5 100644 --- a/app/service/TranslatorService.php +++ b/app/service/TranslatorService.php @@ -23,6 +23,8 @@ class TranslatorService $rst_dst = $this->xunfei->fanyi($var, $fromLang, $targetLang); if ($rst_dst) { $vehicle[$k] = $rst_dst["trans_result"]["dst"]; + }else{ + unset($vehicle[$k]); } } } diff --git a/app/util/Xunfei.php b/app/util/Xunfei.php index 2ccde3d..3d5e3da 100644 --- a/app/util/Xunfei.php +++ b/app/util/Xunfei.php @@ -53,8 +53,8 @@ class Xunfei //在控制台-我的应用-机器翻译获取 $api_key = "b6d805f240176ecaea85130cb5f2bca1"; // 机器翻译接口地址 -// $url = "https://ntrans.xfyun.cn/v2/ots"; - $url = "http://ntrans.example.cn"; + $url = "https://ntrans.xfyun.cn/v2/ots"; +// $url = "http://ntrans.example.cn"; //body组装 // $text = "中华人民共和国于1949年成立";//待翻译文本 $body = json_encode($this->getBody($app_id, $from, $to, $text));