fanyi
This commit is contained in:
@@ -27,6 +27,7 @@ class TranslationJob
|
||||
$sourceLang = $pt['sourceLang'];
|
||||
// $locale = $pt['locale'];
|
||||
$id = $pt['id'];
|
||||
$toLang = $pt['toLang'];
|
||||
|
||||
$translator = new TranslatorService();
|
||||
if($entityType == 'location'){
|
||||
@@ -47,14 +48,15 @@ class TranslationJob
|
||||
}
|
||||
|
||||
$languages = ['cn' => 'cn', 'en' => 'en', 'ru' => 'ru', 'ar' => 'ar'];
|
||||
$languages = array_merge(['to'=>$toLang],$languages);
|
||||
unset($languages[$sourceLang]);
|
||||
log::info('languages', [$languages]);
|
||||
foreach ($languages as $lang => $xflang) {
|
||||
|
||||
if($entityType =='location'){
|
||||
$fields = $translator->location($sourceFields,$lang,$sourceLang);
|
||||
$fields = $translator->location($sourceFields,$xflang,$sourceLang);
|
||||
}else{
|
||||
$fields = $translator->vehicle($sourceFields,$lang,$sourceLang);
|
||||
$fields = $translator->vehicle($sourceFields,$xflang,$sourceLang);
|
||||
}
|
||||
|
||||
$translationModel = $translationModels[$xflang];
|
||||
@@ -66,7 +68,7 @@ class TranslationJob
|
||||
}
|
||||
$translation->fill($fields);
|
||||
$res = $translation->save();
|
||||
log::info('$languages save '.$lang, [$res,$fields]);
|
||||
log::info('$languages save '.$xflang, [$res,$fields]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,11 +43,11 @@ class TranslatorService
|
||||
return $location;
|
||||
}
|
||||
|
||||
public function queue($field,$sourceLang,$type,$id) {
|
||||
public function queue($field,$sourceLang,$type,$id,$toLang) {
|
||||
// 队列名
|
||||
$queue = 'translator';
|
||||
// 数据,可以直接传数组,无需序列化
|
||||
$data = ['entityType' => $type, 'sourceFields' => $field, 'sourceLang' => $sourceLang, 'locale' => 'hello', 'id' => $id];
|
||||
$data = ['entityType' => $type, 'sourceFields' => $field, 'sourceLang' => $sourceLang, 'locale' => 'hello', 'id' => $id, 'toLang' => $toLang];
|
||||
// 投递消息
|
||||
Redis::send($queue, $data);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user