|
...
|
...
|
@@ -26,10 +26,11 @@ class TranslateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取翻译校对文案
|
|
|
|
* @return array
|
|
|
|
* @throws \App\Exceptions\AsideGlobalException
|
|
|
|
* @throws \App\Exceptions\BsideGlobalException
|
|
|
|
* @remark :
|
|
|
|
* @name :getTranslateList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/9 10:59
|
|
|
|
*/
|
|
|
|
public function getTranslateList(){
|
|
|
|
$data = [];
|
|
...
|
...
|
@@ -49,58 +50,6 @@ class TranslateLogic extends BaseLogic |
|
|
|
$languageInfo = $this->getLanguage($this->param['language_id']);
|
|
|
|
// 原始校对内容
|
|
|
|
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
|
|
|
|
if($info !== false){
|
|
|
|
$data_read = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
|
|
|
|
foreach ($data_read as $k => $v){
|
|
|
|
$data[] = [$k => $v];
|
|
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}else{
|
|
|
|
//获取当前URl的所有文本内容
|
|
|
|
$text_array = $this->getUrlRead($url);
|
|
|
|
$i = 0;
|
|
|
|
TranslateText:
|
|
|
|
$translate_list = Translate::tran($text_array, $languageInfo['short']);
|
|
|
|
if(empty($translate_list)){
|
|
|
|
if ($i < 3) {
|
|
|
|
$i++;
|
|
|
|
goto TranslateText;
|
|
|
|
}
|
|
|
|
$this->fail('翻译失败,请稍后重试!');
|
|
|
|
}
|
|
|
|
if(count($text_array) == 1){
|
|
|
|
$data[] = [
|
|
|
|
$text_array[0]=>$translate_list
|
|
|
|
];
|
|
|
|
}else{
|
|
|
|
foreach ($text_array as $k => $v){
|
|
|
|
$data[] = [
|
|
|
|
$v=>$translate_list[$k]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTranslateList(){
|
|
|
|
$data = [];
|
|
|
|
if($this->param['url'] == 'All'){
|
|
|
|
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
|
|
|
|
if(!empty($info) && !empty($info['data'])){
|
|
|
|
$translateInfo = json_decode($info['data'],JSON_UNESCAPED_UNICODE);
|
|
|
|
foreach ($translateInfo as $k => $v){
|
|
|
|
$data[] = [$k=>$v];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
// 需要校对路由
|
|
|
|
$url = $this->user['domain'] . (($this->param['url'] != '/') ? $this->param['url'] : '');
|
|
|
|
// 需要校对语种
|
|
|
|
$languageInfo = $this->getLanguage($this->param['language_id']);
|
|
|
|
// 原始校对内容
|
|
|
|
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
|
|
|
|
//获取当前URl的所有文本内容
|
|
|
|
$text_array = $this->getUrlRead($url);
|
|
|
|
// 原始校对程序
|
...
|
...
|
|