From 5a1c3b4c54fecc1eda103e7badbf1f83ee97d050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:19:15 +0800 Subject: [PATCH] issues/554 issues/558 Update texthook.py 1 1 1 --- .../LunaTranslator/LunaTranslator.py | 11 ++- .../LunaTranslator/gui/settingpage1.py | 67 +++++++++++++++++-- .../LunaTranslator/gui/translatorUI.py | 29 ++++---- .../LunaTranslator/textsource/texthook.py | 17 ++++- .../translator/basetranslator.py | 22 +++--- .../files/defaultconfig/config.json | 4 ++ LunaTranslator/files/lang/ar.json | 15 ++++- LunaTranslator/files/lang/cht.json | 15 ++++- LunaTranslator/files/lang/en.json | 15 ++++- LunaTranslator/files/lang/es.json | 15 ++++- LunaTranslator/files/lang/fr.json | 15 ++++- LunaTranslator/files/lang/it.json | 15 ++++- LunaTranslator/files/lang/ja.json | 15 ++++- LunaTranslator/files/lang/ko.json | 15 ++++- LunaTranslator/files/lang/pl.json | 15 ++++- LunaTranslator/files/lang/ru.json | 15 ++++- LunaTranslator/files/lang/th.json | 15 ++++- LunaTranslator/files/lang/tr.json | 15 ++++- LunaTranslator/files/lang/uk.json | 15 ++++- LunaTranslator/files/lang/vi.json | 15 ++++- LunaTranslator/files/lang/zh.json | 15 ++++- LunaTranslator/trans_lang.py | 2 +- 22 files changed, 325 insertions(+), 52 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 415ff55e..136e5170 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -148,8 +148,7 @@ class MAINUI() : return ss def textgetmethod(self,text,is_auto_run=True,embedcallback=None,onlytrans=False): _autolock(self.solvegottextlock) - if onlytrans==False: - self.currentsignature=time.time() + if type(text)==str: if text.startswith(''): self.translation_ui.displayres.emit(dict(color=globalconfig['rawtextcolor'],res=text[len(''):],onlytrans=onlytrans)) @@ -171,7 +170,8 @@ class MAINUI() : if embedcallback: embedcallback('') return - + if onlytrans==False: + self.currentsignature=time.time() try: if type(text)==list: origin='\n'.join(text) @@ -227,11 +227,11 @@ class MAINUI() : print_exc() hira=[] if globalconfig['refresh_on_get_trans']==False: - self.translation_ui.displayraw1.emit(hira,text,globalconfig['rawtextcolor'] ,onlytrans) + self.translation_ui.displayraw1.emit(dict(hira=hira,text=text,color=globalconfig['rawtextcolor'],onlytrans=onlytrans)) _showrawfunction=None _showrawfunction_sig=0 else: - _showrawfunction=functools.partial(self.translation_ui.displayraw1.emit,hira,text,globalconfig['rawtextcolor'],onlytrans) + _showrawfunction=functools.partial(self.translation_ui.displayraw1.emit,dict(hira=hira,text=text,color=globalconfig['rawtextcolor'],onlytrans=onlytrans)) _showrawfunction_sig=time.time() text_solved,optimization_params= self.solvebeforetrans(text) @@ -274,7 +274,6 @@ class MAINUI() : def GetTranslationCallback(self,onlytrans,classname,currentsignature,optimization_params,_showrawfunction,_showrawfunction_sig,contentraw,res,embedcallback,iter_res_status): - if classname in self.usefultranslators: self.usefultranslators.remove(classname) if embedcallback is None and currentsignature!=self.currentsignature:return diff --git a/LunaTranslator/LunaTranslator/gui/settingpage1.py b/LunaTranslator/LunaTranslator/gui/settingpage1.py index a9d1eee6..8f428626 100644 --- a/LunaTranslator/LunaTranslator/gui/settingpage1.py +++ b/LunaTranslator/LunaTranslator/gui/settingpage1.py @@ -1,15 +1,15 @@ import functools,os,shutil -from PyQt5.QtGui import QFont +from PyQt5.QtGui import QFont,QStandardItem,QStandardItemModel +from PyQt5.QtCore import Qt,QSize from traceback import print_exc -from PyQt5.QtWidgets import QFontComboBox ,QLabel,QComboBox,QPushButton,QFileDialog +from PyQt5.QtWidgets import QFontComboBox,QDialog,QLabel,QComboBox,QPushButton,QFileDialog,QVBoxLayout,QTableView,QHeaderView,QHBoxLayout,QLineEdit from gui.settingpage_ocr import getocrgrid -from myutils.config import globalconfig ,_TR,_TRL ,savehook_new_data -from myutils.hwnd import getpidexe +from myutils.config import globalconfig ,_TR,_TRL from gui.dialog_savedgame import dialog_savedgame import threading,gobject,requests,datetime,zipfile from gui.inputdialog import autoinitdialog -from gui.usefulwidget import getsimplecombobox,getspinbox,getcolorbutton,yuitsu_switch,getsimpleswitch,getQMessageBox +from gui.usefulwidget import getsimplecombobox,getspinbox,getcolorbutton,yuitsu_switch,getsimpleswitch,Singleton from gui.codeacceptdialog import codeacceptdialog from textsource.fridahook import fridahook from myutils.utils import loadfridascriptslist,checkifnewgame,makehtml @@ -130,6 +130,59 @@ def getfridahookgrid(self) : return grids +@Singleton +class safeembedcheckdialog(QDialog): + def newline(self,row): + self.model.insertRow(row,[QStandardItem(globalconfig['embedded']['safecheckregexs'][row])]) + def __init__(self,parent) -> None: + super().__init__(parent,Qt.WindowCloseButtonHint) + self.setWindowTitle(_TR('正则匹配')) + + formLayout = QVBoxLayout(self) # 配置layout + + self.model=QStandardItemModel() + self.model.setHorizontalHeaderLabels(_TRL(['正则'])) + table = QTableView(self) + table.setModel(self.model) + + table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) + + self.table=table + for row,regex in enumerate(globalconfig['embedded']['safecheckregexs']): + self.model.insertRow(row,[QStandardItem(regex)]) + + + button=QPushButton(self) + button.setText(_TR('添加行')) + def clicked1(): + globalconfig['embedded']['safecheckregexs'].insert(0,'') + self.model.insertRow(0,[QStandardItem()]) + button.clicked.connect(clicked1) + button2=QPushButton(self) + button2.setText(_TR('删除选中行')) + def clicked2(): + self.model.removeRow(table.currentIndex().row()) + globalconfig['embedded']['safecheckregexs'].pop(table.currentIndex().row()) + button2.clicked.connect(clicked2) + self.button=button + formLayout.addWidget(table) + formLayout.addWidget(button) + formLayout.addWidget(button2) + self.resize(QSize(600,400)) + self.show() + def closeEvent(self,_) -> None: + self.button.setFocus() + rows=self.model.rowCount() + rowoffset=0 + dedump=set() + for row in range(rows): + regex=self.model.item(row,0).text() + if regex=="" or regex in dedump: + globalconfig['embedded']['safecheckregexs'].pop(row-rowoffset) + rowoffset+=1 + continue + globalconfig['embedded']['safecheckregexs'][row-rowoffset]=regex + dedump.add(regex) def gethookembedgrid(self) : self.gamefont_comboBox = QFontComboBox( ) def callback(x): @@ -149,7 +202,9 @@ def gethookembedgrid(self) : [('内嵌的翻译器',5),'',(getsimplecombobox(_TRL([globalconfig['fanyi'][x]['name'] for x in globalconfig['fanyi']]),globalconfig['embedded'],'translator'),5) ], [('将汉字转换成繁体/日式汉字',5),(getsimpleswitch( globalconfig['embedded'] ,'trans_kanji'),1) ], [('在重叠显示的字间插入空格',5),'',(getsimplecombobox(_TRL(['不插入空格','每个字后插入空格','仅在无法编码的字后插入']),globalconfig['embedded'],'insertspace_policy',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),5) ], - [('修改游戏字体',5),(getsimpleswitch( globalconfig['embedded'] ,'changefont',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),1), (self.gamefont_comboBox,5) ], + [('修改游戏字体',5),(getsimpleswitch( globalconfig['embedded'] ,'changefont',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),1), (self.gamefont_comboBox,5)], + [], + [('内嵌安全性检查',5),getcolorbutton(globalconfig,'',callback=lambda x:safeembedcheckdialog(self),icon='fa.gear',constcolor="#FF69B4")] #[('修改字体字符集',5),(getsimpleswitch( globalconfig['embedded'] ,'changecharset',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),1) ,(getsimplecombobox(_TRL(static_data["charsetmapshow"]),globalconfig['embedded'],'changecharset_charset',callback=lambda _:gobject.baseobject.textsource.flashembedsettings()),5)], ] diff --git a/LunaTranslator/LunaTranslator/gui/translatorUI.py b/LunaTranslator/LunaTranslator/gui/translatorUI.py index 31542890..0a3868cd 100644 --- a/LunaTranslator/LunaTranslator/gui/translatorUI.py +++ b/LunaTranslator/LunaTranslator/gui/translatorUI.py @@ -29,7 +29,7 @@ from gui.usefulwidget import resizableframeless from gui.dialog_savedgame import browserdialog class QUnFrameWindow(resizableframeless): displayres=pyqtSignal(dict) - displayraw1=pyqtSignal(list, str,str,bool) + displayraw1=pyqtSignal(dict) displaystatus=pyqtSignal(str,str,bool,bool) showhideuisignal=pyqtSignal() hookfollowsignal=pyqtSignal(int,tuple) @@ -71,12 +71,12 @@ class QUnFrameWindow(resizableframeless): pass self.move(self.pos().x()+ other[0],self.pos().y()+ other[1]) - def showres(self,kwargs):#name,color,res,onlyshowhist,iter_context): + def showres(self,kwargs):#name,color,res,onlytrans,iter_context): try: name=kwargs.get('name','') color=kwargs.get('color') res=kwargs.get('res') - onlyshowhist=kwargs.get('onlyshowhist') + onlytrans=kwargs.get('onlytrans') iter_context=kwargs.get('iter_context',None) if iter_context: @@ -87,8 +87,8 @@ class QUnFrameWindow(resizableframeless): else: gobject.baseobject.transhis.getnewtranssignal.emit(name,res) - if onlyshowhist: - return + if onlytrans: + return clear=name=='' if len(res)>globalconfig['maxoriginlength']: _res=res[:globalconfig['maxoriginlength']]+'……' @@ -103,15 +103,20 @@ class QUnFrameWindow(resizableframeless): except: print_exc() - def showraw(self,hira,res,color ,onlyshowhist): + def showraw(self,kwargs):#hira,res,color,onlytrans): + hira=kwargs.get('hira') + text=kwargs.get('text') + color=kwargs.get('color') + onlytrans=kwargs.get('onlytrans') + clear=True - gobject.baseobject.transhis.getnewsentencesignal.emit(res) - if onlyshowhist: + gobject.baseobject.transhis.getnewsentencesignal.emit(text) + if onlytrans: return - if len(res)>globalconfig['maxoriginlength']: - _res=res[:globalconfig['maxoriginlength']]+'……' + if len(text)>globalconfig['maxoriginlength']: + _res=text[:globalconfig['maxoriginlength']]+'……' else: - _res=res + _res=text if globalconfig['isshowhira'] and globalconfig['isshowrawtext']: self.showline(clear=clear,text=_res,hira=hira,color=color) elif globalconfig['isshowrawtext']: @@ -119,7 +124,7 @@ class QUnFrameWindow(resizableframeless): else: self.showline(clear=clear) - gobject.baseobject.edittextui.getnewsentencesignal.emit(res) + gobject.baseobject.edittextui.getnewsentencesignal.emit(text) def showstatus(self,res,color,clear,origin): self.showline(clear=clear,text=res,color=color,origin=origin) def showline (self,**kwargs):# clear,res,color ,type_=1,origin=True): diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index c3b16fe3..ac8de3a0 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -3,7 +3,7 @@ from queue import Queue import re ,os import time ,gobject from collections import OrderedDict -import ctypes,functools +import codecs,functools import windows,subprocess from myutils.config import globalconfig ,savehook_new_data ,_TR,static_data from textsource.textsourcebase import basetext @@ -201,8 +201,19 @@ class texthook(basetext ): def newhookinsert(self,addr,hcode): for _hc,_addr,_ctx1,_ctx2 in savehook_new_data[self.pname]['embedablehook']: if hcode==_hc: - self.useembed(addr,_ctx1,_ctx2,True) - def getembedtext(self,text,tp): + self.useembed(addr,_ctx1,_ctx2,True) + def safeembedcheck(self,text): + try: + for regex in (globalconfig['embedded']['safecheckregexs']): + if re.match(codecs.escape_decode(bytes(regex,"utf-8"))[0].decode("utf-8"),text): + return False + return True + except: + return False + def getembedtext(self,text,tp): + if self.safeembedcheck(text)==False: + self.embedcallback(text,text) + return if globalconfig['autorun']==False: self.embedcallback(text,text) return diff --git a/LunaTranslator/LunaTranslator/translator/basetranslator.py b/LunaTranslator/LunaTranslator/translator/basetranslator.py index 2270e15f..aaf3fccc 100644 --- a/LunaTranslator/LunaTranslator/translator/basetranslator.py +++ b/LunaTranslator/LunaTranslator/translator/basetranslator.py @@ -76,7 +76,11 @@ class basetrans(commonbase): self.multiapikeycurrentidx=-1 self.queue=Queue() self.sqlqueue=None - self._safe_private_init() + try: + self._private_init() + except Exception as e: + gobject.baseobject.textgetmethod(''+globalconfig['fanyi'][self.typename]['name']+' inittranslator failed : '+str(stringfyerror(e))) + print_exc() self.lastrequesttime=0 self.requestid=0 @@ -96,18 +100,14 @@ class basetrans(commonbase): self.sqlqueue=Queue() Thread(target= self._sqlitethread).start() Thread(target=self._fythread).start() - def _safe_private_init(self): - try: - self._private_init() - except Exception as e: - gobject.baseobject.textgetmethod(''+globalconfig['fanyi'][self.typename]['name']+' inittranslator failed : '+str(stringfyerror(e))) - print_exc() def notifyqueuforend(self): if self.sqlqueue: self.sqlqueue.put(None) self.queue.put(None) def _private_init(self): + self.initok=False self.inittranslator() + self.initok=True def _sqlitethread(self): while self.using: task=self.sqlqueue.get() @@ -252,11 +252,15 @@ class basetrans(commonbase): checktutukufunction=lambda:( (embedcallback is not None) or self.queue.empty()) and self.using if checktutukufunction(): def reinitandtrans(): - if self.needreinit: + if self.needreinit or self.initok==False: self.needreinit=False self.renewsesion() - self._private_init() + try: + self._private_init() + except Exception as e: + raise Exception('inittranslator failed : '+str(stringfyerror(e))) return self.maybecachetranslate(contentraw,contentsolved,hira,is_auto_run) + res=timeoutfunction(reinitandtrans,checktutukufunction=checktutukufunction ) collectiterres=[] def __callback(_,is_iter_res): diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index fa703ff3..9d9472a6 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -17,6 +17,10 @@ "direct_filterrepeat":false, "allow_set_text_name":false, "embedded": { + "safecheckregexs": [ + "(.*?)\\{(.*?)\\}(.*?)", + "(.*?)\\[(.*?)\\](.*?)" + ], "translator": 0, "as_fast_as_posible": true, "timeout_translate": 2, diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index e4ea9007..fcab64e1 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -715,5 +715,18 @@ "命令行启动": "بدء تشغيل سطر الأوامر", "文本相似度阈值": "نص التشابه العتبة", "正则": "الكنسي", - "流式输出": "تدفق الانتاج" + "流式输出": "تدفق الانتاج", + "内嵌安全性检查": "جزءا لا يتجزأ من فحص السلامة", + "正则匹配": "مطابقة العادية", + "TGW懒人包": "TGW الكسول حقيبة", + "TGW懒人包1": "TGW الكسول حزمة 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "واجهة المعهد عنوان http://127.0.0.1:5000/ و", + "利用上文信息翻译": "استخدام المعلومات الواردة أعلاه في الترجمة", + "附带上下文个数(必须打开利用上文翻译)": "مع عدد من السياقات ( يجب فتح باستخدام الترجمة أعلاه )", + "prompt(系统人设)": "Prompt ( النظام )", + "prompt(文本起始)": "Prompt ( بداية النص )", + "prompt(不懂可以不写)": "prompt ( لا يمكن أن نفهم لا تكتب )", + "stop(自定义停止符,多个用逗号隔开)": "توقف ( عادة توقف ، مفصولة بفواصل متعددة )", + "tokens(单次生成上限)": "الرموز ( واحد توليد الحد الأعلى )", + "template(需要按照模型模板选择)": "template ( تحتاج إلى اختيار وفقا لنموذج القالب )" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 2962d29d..0a049fa9 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -715,5 +715,18 @@ "命令行启动": "命令列啟動", "文本相似度阈值": "文字相似度閾值", "正则": "正則", - "流式输出": "流式輸出" + "流式输出": "流式輸出", + "内嵌安全性检查": "內嵌安全性檢查", + "正则匹配": "正則匹配", + "TGW懒人包": "TGW懶人包", + "TGW懒人包1": "TGW懶人包1", + "API接口地址(默认为http://127.0.0.1:5000/)": "API介面地址(默認為 http://127.0.0.1:5000/ )", + "利用上文信息翻译": "利用上文資訊翻譯", + "附带上下文个数(必须打开利用上文翻译)": "附帶上下文個數(必須打開利用上文翻譯)", + "prompt(系统人设)": "prompt(系統人設)", + "prompt(文本起始)": "prompt(文字起始)", + "prompt(不懂可以不写)": "prompt(不懂可以不寫)", + "stop(自定义停止符,多个用逗号隔开)": "stop(自定義停止符,多個用逗號隔開)", + "tokens(单次生成上限)": "tokens(單次生成上限)", + "template(需要按照模型模板选择)": "template(需要按照模型範本選擇)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 03678ba7..6e5ab23a 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -715,5 +715,18 @@ "命令行启动": "Command line startup", "文本相似度阈值": "Text similarity threshold", "正则": "Regular", - "流式输出": "Streaming output" + "流式输出": "Streaming output", + "内嵌安全性检查": "Embedded security check", + "正则匹配": "Regular matching", + "TGW懒人包": "TGW Lazy Bag", + "TGW懒人包1": "TGW Lazy Bag 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "API interface address (default to http://127.0.0.1:5000/ )", + "利用上文信息翻译": "Translate using the information from the previous text", + "附带上下文个数(必须打开利用上文翻译)": "Number of accompanying contexts (must be opened and translated using the previous text)", + "prompt(系统人设)": "Prompt (system persona)", + "prompt(文本起始)": "Prompt (start of text)", + "prompt(不懂可以不写)": "Prompt (can be omitted if not understood)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (custom stop character, multiple separated by commas)", + "tokens(单次生成上限)": "Tokens (upper limit of single generation)", + "template(需要按照模型模板选择)": "Template (needs to be selected according to the model template)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index ef727673..68c8fd00 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -715,5 +715,18 @@ "命令行启动": "Se inicia la línea de órdenes", "文本相似度阈值": "Umbral de similitud de texto", "正则": "Regular", - "流式输出": "Salida de flujo" + "流式输出": "Salida de flujo", + "内嵌安全性检查": "Inspección de Seguridad incorporada", + "正则匹配": "Coincidencia regular", + "TGW懒人包": "Bolsa perezosa tgw", + "TGW懒人包1": "Paquete perezoso tgw 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Dirección de la interfaz API (por defecto http://127.0.0.1:5000/ (...)", + "利用上文信息翻译": "Traducción utilizando la información anterior", + "附带上下文个数(必须打开利用上文翻译)": "Número de contextos adjuntos (debe abrirse para usar la traducción anterior)", + "prompt(系统人设)": "Prompt (configuración humana del sistema)", + "prompt(文本起始)": "Prompt (inicio del texto)", + "prompt(不懂可以不写)": "Prompt (no se puede escribir si no se entiende)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (stop personalizado, varios separados por comas)", + "tokens(单次生成上限)": "Tokens (límite superior de generación única)", + "template(需要按照模型模板选择)": "Plantilla (se debe seleccionar de acuerdo con la plantilla del modelo)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index c8808761..a59829df 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -715,5 +715,18 @@ "命令行启动": "Démarrage de la ligne de commande", "文本相似度阈值": "Seuil de similarité du texte", "正则": "Régulière", - "流式输出": "Sortie de flux" + "流式输出": "Sortie de flux", + "内嵌安全性检查": "Inspection de sécurité intégrée", + "正则匹配": "Match régulier", + "TGW懒人包": "Tgw sac pour paresseux", + "TGW懒人包1": "Tgw sac paresseux 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Adresse de l'interface API (par défaut http://127.0.0.1:5000/ ) et", + "利用上文信息翻译": "Traduire avec les informations ci - dessus", + "附带上下文个数(必须打开利用上文翻译)": "Livré avec le nombre de contextes (doit être ouvert pour tirer parti de la traduction ci - dessus)", + "prompt(系统人设)": "Prompt (configuration du système)", + "prompt(文本起始)": "Prompt (début du texte)", + "prompt(不懂可以不写)": "Prompt (ne sait pas écrire)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (STOP personnalisé, plusieurs séparés par des virgules)", + "tokens(单次生成上限)": "Tokens (limite supérieure de génération unique)", + "template(需要按照模型模板选择)": "Template (doit être choisi selon le modèle de modèle)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index 5d713090..3d605313 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -715,5 +715,18 @@ "命令行启动": "Avvio della riga di comando", "文本相似度阈值": "Soglia di somiglianza del testo", "正则": "regolare", - "流式输出": "Uscita in streaming" + "流式输出": "Uscita in streaming", + "内嵌安全性检查": "Controllo di sicurezza integrato", + "正则匹配": "Corrispondenza regolare", + "TGW懒人包": "TGW Lazy Bag", + "TGW懒人包1": "TGW Lazy Bag 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Indirizzo interfaccia API (default to http://127.0.0.1:5000/ )", + "利用上文信息翻译": "Traduci usando le informazioni del testo precedente", + "附带上下文个数(必须打开利用上文翻译)": "Numero di contesti di accompagnamento (devono essere aperti e tradotti utilizzando il testo precedente)", + "prompt(系统人设)": "Prompt (persona di sistema)", + "prompt(文本起始)": "Richiesta (inizio del testo)", + "prompt(不懂可以不写)": "Prompt (può essere omesso se non compreso)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (carattere di arresto personalizzato, multipli separati da virgole)", + "tokens(单次生成上限)": "Token (limite superiore di singola generazione)", + "template(需要按照模型模板选择)": "Modello (deve essere selezionato in base al modello)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 6b1c8ab3..46a722dc 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -715,5 +715,18 @@ "命令行启动": "コマンドライン起動", "文本相似度阈值": "テキスト類似度しきい値", "正则": "正則", - "流式输出": "ストリーム出力" + "流式输出": "ストリーム出力", + "内嵌安全性检查": "インラインセキュリティチェック", + "正则匹配": "正規一致", + "TGW懒人包": "TGW怠け者バッグ", + "TGW懒人包1": "TGW怠け者バッグ1", + "API接口地址(默认为http://127.0.0.1:5000/)": "APIインタフェースアドレス(デフォルトはhttp://127.0.0.1:5000/)", + "利用上文信息翻译": "上記の情報翻訳を利用する", + "附带上下文个数(必须打开利用上文翻译)": "付帯コンテキスト数(上記の翻訳を使用するにはオンにする必要があります)", + "prompt(系统人设)": "prompt(システムキャラクタセット)", + "prompt(文本起始)": "prompt(テキスト開始)", + "prompt(不懂可以不写)": "prompt(分からなくても書かなくてもいい)", + "stop(自定义停止符,多个用逗号隔开)": "stop(コンマで区切られたカスタム停止子)", + "tokens(单次生成上限)": "tokens(単回生成上限)", + "template(需要按照模型模板选择)": "template(モデルテンプレートに従って選択する必要がある)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 5cdc4e4e..fbb9dbd0 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -715,5 +715,18 @@ "命令行启动": "명령줄 시작", "文本相似度阈值": "텍스트 유사도 임계값", "正则": "정규", - "流式输出": "스트리밍 출력" + "流式输出": "스트리밍 출력", + "内嵌安全性检查": "내장 보안 검사", + "正则匹配": "정규 일치", + "TGW懒人包": "TGW 게으름뱅이 가방", + "TGW懒人包1": "TGW 게으름뱅이 가방 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "API 인터페이스 주소(기본값)http://127.0.0.1:5000/)", + "利用上文信息翻译": "위의 정보를 이용하여 번역하다.", + "附带上下文个数(必须打开利用上文翻译)": "첨부된 컨텍스트 개수 (위의 번역을 사용하려면 열어야 함)", + "prompt(系统人设)": "prompt(시스템 설정)", + "prompt(文本起始)": "prompt(텍스트 시작)", + "prompt(不懂可以不写)": "prompt(모르면 쓰지 않아도 됨)", + "stop(自定义停止符,多个用逗号隔开)": "stop (사용자 정의 정지자, 쉼표로 구분된 여러 개)", + "tokens(单次生成上限)": "tokens(단일 생성 상한)", + "template(需要按照模型模板选择)": "template(모델 템플릿별로 선택 필요)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index c1ba828d..acd22457 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -715,5 +715,18 @@ "命令行启动": "Uruchamianie wiersza poleceń", "文本相似度阈值": "Próg podobieństwa tekstu", "正则": "regularne", - "流式输出": "Wyjście strumieniowe" + "流式输出": "Wyjście strumieniowe", + "内嵌安全性检查": "Wbudowana kontrola bezpieczeństwa", + "正则匹配": "Regularne dopasowanie", + "TGW懒人包": "TGW Lazy Bag", + "TGW懒人包1": "TGW Lazy Bag 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Adres interfejsu API (domyślnie http://127.0.0.1:5000/ )", + "利用上文信息翻译": "Przetłumacz za pomocą informacji z poprzedniego tekstu", + "附带上下文个数(必须打开利用上文翻译)": "Liczba kontekstów towarzyszących (należy otworzyć i przetłumaczyć za pomocą poprzedniego tekstu)", + "prompt(系统人设)": "Zapytanie (osoba systemowa)", + "prompt(文本起始)": "Pytanie (początek tekstu)", + "prompt(不懂可以不写)": "Zapytanie (może być pominięte, jeśli nie jest zrozumiane)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (niestandardowy znak stop, wielokrotnie oddzielony przecinkami)", + "tokens(单次生成上限)": "Tokeny (górna granica pojedynczej generacji)", + "template(需要按照模型模板选择)": "Szablon (należy wybrać według szablonu modelu)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 8b24764a..bb35a0a3 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -715,5 +715,18 @@ "命令行启动": "Запуск командной строки", "文本相似度阈值": "Порог сходства текста", "正则": "Регулярно", - "流式输出": "Поточный вывод" + "流式输出": "Поточный вывод", + "内嵌安全性检查": "Проверка встроенной безопасности", + "正则匹配": "Регулярное согласование", + "TGW懒人包": "ТГВ сумка лентяй", + "TGW懒人包1": "TGW Ленивый мешок 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Адрес интерфейса API (по умолчанию http://127.0.0.1:5000/ )", + "利用上文信息翻译": "Перевод с использованием вышеуказанной информации", + "附带上下文个数(必须打开利用上文翻译)": "Количество дополнительных контекстных единиц (необходимо открыть с использованием перевода выше)", + "prompt(系统人设)": "prompt (Системный человек)", + "prompt(文本起始)": "prompt (Начало текста)", + "prompt(不懂可以不写)": "PROMPT (Не умеешь писать)", + "stop(自定义停止符,多个用逗号隔开)": "Стоп (настраиваемый стоп - символ, несколько разделены запятыми)", + "tokens(单次生成上限)": "Токены (верхний предел однократной генерации)", + "template(需要按照模型模板选择)": "Template (необходимо выбрать по шаблону модели)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 82623f92..f373ad3a 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -715,5 +715,18 @@ "命令行启动": "เริ่มบรรทัดคำสั่ง", "文本相似度阈值": "เกณฑ์ความคล้ายคลึงกันของข้อความ", "正则": "กฎทั่วไป", - "流式输出": "สตรีมเอาท์พุท" + "流式输出": "สตรีมเอาท์พุท", + "内嵌安全性检查": "การตรวจสอบความปลอดภัยแบบอินไลน์", + "正则匹配": "จับคู่ปกติ", + "TGW懒人包": "กระเป๋า TGW Lazy", + "TGW懒人包1": "แพ็คเกจ TGW Lazy 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "ที่อยู่อินเทอร์เฟซ API (ค่าเริ่มต้นคือ http://127.0.0.1:5000/ )", + "利用上文信息翻译": "ใช้การแปลข้อมูลข้างต้น", + "附带上下文个数(必须打开利用上文翻译)": "มาพร้อมกับจำนวนรายการบริบท (ต้องเปิดเพื่อใช้ประโยชน์จากการแปลข้างต้น)", + "prompt(系统人设)": "prompt (ระบบมนุษย์)", + "prompt(文本起始)": "prompt (เริ่มต้นข้อความ)", + "prompt(不懂可以不写)": "prompt (ไม่เข้าใจสามารถเขียน)", + "stop(自定义停止符,多个用逗号隔开)": "หยุด (ตัวหยุดแบบกำหนดเองหลายตัวคั่นด้วยเครื่องหมายจุลภาค)", + "tokens(单次生成上限)": "โทเคนส์ (ขีดจำกัดการสร้างเพียงครั้งเดียว)", + "template(需要按照模型模板选择)": "เทมเพลต (ต้องเลือกตามแม่แบบรุ่น)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index eeba5c37..c5a58048 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -715,5 +715,18 @@ "命令行启动": "Komut satırı başlatma", "文本相似度阈值": "Metin benzerliği eşiği", "正则": "normal", - "流式输出": "Aktarma çıkışı" + "流式输出": "Aktarma çıkışı", + "内嵌安全性检查": "İçeri giriş güvenlik kontrolü", + "正则匹配": "Normal eşleşme", + "TGW懒人包": "TGW Lazy Bag", + "TGW懒人包1": "TGW Lazy Bag 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "API arayüz adresi (öntanımlı olarak) http://127.0.0.1:5000/ - Evet.", + "利用上文信息翻译": "Önceki metinden bilgi kullanarak çevirin", + "附带上下文个数(必须打开利用上文翻译)": "İlerleyen anlaşmalar sayısı (önceki metin kullanarak açılıp çevirilmeli olmalı)", + "prompt(系统人设)": "Soru (sistem kişisi)", + "prompt(文本起始)": "Soru (metin başlaması)", + "prompt(不懂可以不写)": "Soru (anlamazsa terk edilebilir)", + "stop(自定义停止符,多个用逗号隔开)": "Dur (özel durma karakteri, komuta ile birçok ayrı)", + "tokens(单次生成上限)": "Tokenler (tek nesilin üst sınırı)", + "template(需要按照模型模板选择)": "Şablon (model şablona göre seçilmeli)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index a8ec05ce..a9ee5af6 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -715,5 +715,18 @@ "命令行启动": "Запуск командного рядка", "文本相似度阈值": "Праг подібності до тексту", "正则": "звичайний", - "流式输出": "Вивід потоку" + "流式输出": "Вивід потоку", + "内嵌安全性检查": "Вбудована перевірка безпеки", + "正则匹配": "Регулярне збігання", + "TGW懒人包": "TGW Lazy Bag", + "TGW懒人包1": "TGW Lazy Bag 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Адреса інтерфейсу API (типова для http://127.0.0.1:5000/ 65289;", + "利用上文信息翻译": "Переклад за допомогою інформації з попереднього тексту", + "附带上下文个数(必须打开利用上文翻译)": "Кількість приєднаних контекстів (слід відкрити і перекладати за допомогою попереднього тексту)", + "prompt(系统人设)": "Запит (системна особистість)", + "prompt(文本起始)": "Запитати (початок тексту)", + "prompt(不懂可以不写)": "Запитати (можна пропустити, якщо не розуміється)", + "stop(自定义停止符,多个用逗号隔开)": "Зупинити (нетиповий символ зупинки, декілька відокремлених комами)", + "tokens(单次生成上限)": "Токени (верхня межа одного покоління)", + "template(需要按照模型模板选择)": "Шаблон (потрібно вибрати за допомогою шаблону моделі)" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 50d480ca..a005a8cf 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -715,5 +715,18 @@ "命令行启动": "Chạy dòng lệnh", "文本相似度阈值": "Ngưỡng tương tự văn bản", "正则": "Chính quy", - "流式输出": "Đầu ra dòng" + "流式输出": "Đầu ra dòng", + "内嵌安全性检查": "Kiểm tra an ninh nội tuyến", + "正则匹配": "Khớp chính quy", + "TGW懒人包": "Túi xách lười TGW", + "TGW懒人包1": "Túi xách lười TGW 1", + "API接口地址(默认为http://127.0.0.1:5000/)": "Địa chỉ giao diện API (mặc định là http://127.0.0.1:5000/ )", + "利用上文信息翻译": "Sử dụng thông tin trên để dịch", + "附带上下文个数(必须打开利用上文翻译)": "Kèm theo số ngữ cảnh (phải được mở để sử dụng bản dịch ở trên)", + "prompt(系统人设)": "Prompt (hệ thống)", + "prompt(文本起始)": "Prompt (văn bản bắt đầu)", + "prompt(不懂可以不写)": "Prompt (không hiểu có thể viết)", + "stop(自定义停止符,多个用逗号隔开)": "Stop (dừng tùy chỉnh, nhiều ngăn cách bằng dấu phẩy)", + "tokens(单次生成上限)": "Tokens (Giới hạn phát sinh một lần)", + "template(需要按照模型模板选择)": "REFERENCES [Tên bảng tham chiếu] (" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 6b97a98a..8dc0e886 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -715,5 +715,18 @@ "命令行启动": "", "文本相似度阈值": "", "正则": "", - "流式输出": "" + "流式输出": "", + "内嵌安全性检查": "", + "正则匹配": "", + "TGW懒人包": "", + "TGW懒人包1": "", + "API接口地址(默认为http://127.0.0.1:5000/)": "", + "利用上文信息翻译": "", + "附带上下文个数(必须打开利用上文翻译)": "", + "prompt(系统人设)": "", + "prompt(文本起始)": "", + "prompt(不懂可以不写)": "", + "stop(自定义停止符,多个用逗号隔开)": "", + "tokens(单次生成上限)": "", + "template(需要按照模型模板选择)": "" } \ No newline at end of file diff --git a/LunaTranslator/trans_lang.py b/LunaTranslator/trans_lang.py index 8287692f..7d496fb4 100644 --- a/LunaTranslator/trans_lang.py +++ b/LunaTranslator/trans_lang.py @@ -1,6 +1,6 @@ import sys,time sys.path.append('./LunaTranslator') -from translator.baidu import TS +from translator.baidu_ai import TS class TS1(TS): @property