|
|
@@ -4,8 +4,8 @@
|
|
|
width="800px"
|
|
|
custom-class="multilingual-fill-dialog"
|
|
|
:close-on-click-modal="false"
|
|
|
- @close="closeDialog"
|
|
|
append-to-body
|
|
|
+ @close="closeDialog"
|
|
|
>
|
|
|
<div class="multilingual-fill">
|
|
|
<div class="left-menu">
|
|
|
@@ -37,6 +37,9 @@
|
|
|
<span class="btn primary" @click="submitTranslation">
|
|
|
<span>提交译文</span>
|
|
|
</span>
|
|
|
+ <span class="btn primary" @click="textTrans">
|
|
|
+ <span>自动翻译</span>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
<i class="el-icon-close" @click="closeDialog"></i>
|
|
|
</div>
|
|
|
@@ -65,6 +68,7 @@
|
|
|
import UpdateLang from './UpdateLang.vue';
|
|
|
|
|
|
import { sanitizeHTML } from '@/utils/common';
|
|
|
+import { TextTrans } from '@/api/app';
|
|
|
|
|
|
export default {
|
|
|
name: 'MultilingualFill',
|
|
|
@@ -152,6 +156,22 @@ export default {
|
|
|
...newLangs.map((item) => ({ type: item, translation: '' })),
|
|
|
];
|
|
|
},
|
|
|
+ textTrans() {
|
|
|
+ TextTrans({
|
|
|
+ text: this.text.replace(/<[^>]+>/g, ''),
|
|
|
+ from: 'zh',
|
|
|
+ to: this.curLang.toLowerCase(),
|
|
|
+ }).then(({ trans_list }) => {
|
|
|
+ console.log(trans_list);
|
|
|
+ if (trans_list.length > 0) {
|
|
|
+ const transText = trans_list[0].dst;
|
|
|
+ const curLangItem = this.selectedLangList.find((item) => item.type === this.curLang);
|
|
|
+ if (curLangItem) {
|
|
|
+ curLangItem.translation = transText;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
submitTranslation() {
|
|
|
this.$emit('SubmitTranslation', this.selectedLangList);
|
|
|
this.closeDialog();
|