This commit is contained in:
恍兮惚兮 2024-09-27 15:50:13 +08:00
parent 1f097a6d27
commit 6e90cf4cb1
26 changed files with 15 additions and 212 deletions

View File

@ -70,7 +70,6 @@ class MAINUI:
self.gettranslatelock = threading.Lock()
self.outputers = {}
self.processmethods = []
self.zhanweifu = 0
self.AttachProcessDialog = None
self.edittextui = None
self.edittextui_cached = None
@ -202,7 +201,6 @@ class MAINUI:
def solvebeforetrans(self, content):
contexts = []
self.zhanweifu = 0
for method in self.processmethods:
context = None
try:

View File

@ -23,6 +23,9 @@ def list_models(typename, regist):
class gptcommon(basetrans):
@property
def apiurl(self):
return self.config.get("API接口地址", self.config.get("OPENAI_API_BASE", ""))
def langmap(self):
return createenglishlangmap()
@ -44,7 +47,7 @@ class gptcommon(basetrans):
temperature=temperature,
stream=self.config["流式输出"],
)
if "api.mistral.ai" not in self.config["API接口地址"]:
if "api.mistral.ai" not in self.apiurl:
data.update(dict(frequency_penalty=self.config["frequency_penalty"]))
try:
if self.config["use_other_args"]:
@ -56,7 +59,7 @@ class gptcommon(basetrans):
def createheaders(self):
_ = {"Authorization": "Bearer " + self.multiapikeycurrent["SECRET_KEY"]}
if "openai.azure.com/openai/deployments/" in self.config.get("API接口地址", ""):
if "openai.azure.com/openai/deployments/" in self.apiurl:
_.update({"api-key": self.multiapikeycurrent["SECRET_KEY"]})
return _
@ -132,6 +135,6 @@ class gptcommon(basetrans):
return self.commonparseresponse(query, response, usingstream)
def createurl(self):
if "openai.azure.com/openai/deployments/" in self.config["API接口地址"]:
return self.config["API接口地址"]
return createurl(self.config["API接口地址"])
if "openai.azure.com/openai/deployments/" in self.apiurl:
return self.apiurl
return createurl(self.apiurl)

View File

@ -1,155 +0,0 @@
from myutils.config import globalconfig
from myutils.utils import case_insensitive_replace
import xml.etree.ElementTree as ET
import os, gobject, re
from gui.inputdialog import getsomepath1
def vnrshareddict(self):
self.vnrshareddict = {}
self.vnrshareddict_pre = {}
self.vnrshareddict_post = {}
self.sorted_vnrshareddict = []
self.sorted_vnrshareddict_pre = []
self.sorted_vnrshareddict_post = []
self.vnrsharedreg = []
if globalconfig["gongxiangcishu"]["use"] and os.path.exists(
globalconfig["gongxiangcishu"]["path"]
):
xml = ET.parse(globalconfig["gongxiangcishu"]["path"])
for _ in xml.find("terms").findall("term"):
# print(_.get('type'))
# macro 宏(正则) 忽略
# yomi 人名读音 可忽略
# input 直接替换
# trans 翻译优化
# output 输出替换
# tts 忽略
# game #游戏名 忽略
# name #人名 忽略
# suffix #后缀(们)等 忽略
# prefix #前缀 忽略
_type = _.get("type")
try:
src = _.find("sourceLanguage").text
tgt = _.find("language").text
if tgt == "en":
continue
pattern = _.find("pattern").text
try:
text = _.find("text").text
except:
text = ""
try:
regex = _.find("regex").text
except:
if "eos" in text or "amp" in text or "&" in text:
continue
if _type == "trans":
self.vnrshareddict[pattern] = {
"src": src,
"tgt": tgt,
"text": text,
}
elif _type == "input":
self.vnrshareddict_pre[pattern] = {
"src": src,
"tgt": tgt,
"text": text,
}
elif _type == "output":
self.vnrshareddict_post[pattern] = {
"src": src,
"tgt": tgt,
"text": text,
}
except:
pass
keys = list(self.vnrshareddict.keys())
keys.sort(key=lambda key: len(key), reverse=True)
self.sorted_vnrshareddict = [(key, self.vnrshareddict[key]) for key in keys]
keys = list(self.vnrshareddict_pre.keys())
keys.sort(key=lambda key: len(key), reverse=True)
self.sorted_vnrshareddict_pre = [
(key, self.vnrshareddict_pre[key]) for key in keys
]
keys = list(self.vnrshareddict_post.keys())
keys.sort(key=lambda key: len(key), reverse=True)
self.sorted_vnrshareddict_post = [
(key, self.vnrshareddict_post[key]) for key in keys
]
class Process:
def __init__(self) -> None:
self.status = None
self.checkchange()
def checkchange(self):
s = (
globalconfig["gongxiangcishu"]["use"],
globalconfig["gongxiangcishu"]["path"],
)
if self.status != s:
self.status = s
vnrshareddict(self)
def process_before(self, content):
___idx = 1
self.checkchange()
context = {}
for key, value in self.sorted_vnrshareddict_pre:
if key in content:
content = content.replace(key, value["text"])
for key, value in self.sorted_vnrshareddict:
if key in content:
# print(key)
# if self.vnrshareddict[key]['src']==self.vnrshareddict[key]['tgt']:
# content=content.replace(key,self.vnrshareddict[key]['text'])
# else:
if ___idx == 1:
xx = "ZX{}Z".format(chr(ord("B") + gobject.baseobject.zhanweifu))
elif ___idx == 2:
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
elif ___idx == 3:
xx = key
content = content.replace(key, xx)
context[xx] = key
gobject.baseobject.zhanweifu += 1
return content, context
def process_after(self, res: str, context):
for key in context:
res = case_insensitive_replace(
res, key, self.vnrshareddict[context[key]]["text"]
)
for key, value in self.sorted_vnrshareddict_post:
if key in res:
res = res.replace(key, value["text"])
return res
@staticmethod
def get_setting_window(parent_window):
return getsomepath1(
parent_window,
"共享辞书",
globalconfig["gongxiangcishu"],
"path",
"共享辞书",
None,
False,
"*.xml",
)

View File

@ -49,10 +49,10 @@ class Process:
def __createfake(self):
___idx = 1
if ___idx == 1:
xx = "ZX{}Z".format(chr(ord("B") + gobject.baseobject.zhanweifu))
xx = "ZX{}Z".format(chr(ord("B") + self.zhanweifu))
elif ___idx == 2:
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
gobject.baseobject.zhanweifu += 1
xx = "{{{}}}".format(self.zhanweifu)
self.zhanweifu += 1
return xx
def process_before(self, japanese):
@ -68,6 +68,8 @@ class Process:
continue
gpt_dict.append(gpt)
used.append((src, gpt["dst"]))
self.zhanweifu = 0
japanese1, mp1 = self.process_before1(japanese, used)
return japanese1, {

View File

@ -335,7 +335,6 @@
"transoptimi": {
"noundict": false,
"transerrorfix": false,
"gongxiangcishu": false,
"vndbnamemap": false,
"myprocess": false,
"arabic_reshaper": false
@ -2052,10 +2051,6 @@
"ocrmininterval": 1,
"selectable": false,
"autoupdate": true,
"gongxiangcishu": {
"use": false,
"path": ""
},
"proxies": null,
"viewlistpos": 0,
"textoutput_origin": true,

View File

@ -388,7 +388,6 @@
"目标语言": "اللغة المستهدفة",
"火山OCR": "بركان التعرف الضوئي على الحروف",
"秒": "ثانية .",
"共享辞书": "قاموس مشترك",
"时间周期执行": "فترة التنفيذ",
"录制翻译文件": "تسجيل ملف الترجمة",
"锁定工具栏": "قفل شريط الأدوات",
@ -705,7 +704,6 @@
"条件": "شرط .",
"指定人名翻译": "تعيين اسم المترجم",
"专有名词翻译": "ترجمة الأسماء الصحيحة",
"VNR共享辞书": "vnr قاموس مشترك",
"自定义优化": "عرف التحسين",
"人名": "اسم الشخص",
"游戏数据": "بيانات اللعبة",

View File

@ -127,7 +127,6 @@
"图标": "圖示",
"指示詞": "指示詞",
"動詞": "動詞",
"共享辞书": "共享辭書",
"注册网址": "註冊網址",
"显示帧率": "顯示幀率",
"游戏": "遊戲",
@ -705,7 +704,6 @@
"条件": "條件",
"指定人名翻译": "指定人名翻譯",
"专有名词翻译": "專有名詞翻譯",
"VNR共享辞书": "VNR 共享辭書",
"自定义优化": "自訂優化",
"人名": "人名",
"游戏数据": "遊戲資料",

View File

@ -431,7 +431,6 @@
"起始地址(hex)": "Počáteční adresa (hex)",
"说明": "vysvětlit",
"处理": "rukojeť",
"共享辞书": "Sdílený slovník",
"助動詞": "Pomocné sloveso",
"选择文件": "Vybrat soubor",
"自动翻译": "Automatický překlad",
@ -706,7 +705,6 @@
"条件": "stav",
"指定人名翻译": "Překlad označeného názvu",
"专有名词翻译": "Překlad vlastnických pojmů",
"VNR共享辞书": "Sdílený slovník VNR",
"自定义优化": "Vlastní optimalizace",
"人名": "jméno",
"游戏数据": "Údaje o hře",

View File

@ -431,7 +431,6 @@
"起始地址(hex)": "Startadresse (Hex)",
"说明": "erklären",
"处理": "Handle",
"共享辞书": "Gemeinsames Wörterbuch",
"助動詞": "Hilfsverb",
"选择文件": "Datei auswählen",
"自动翻译": "Automatische Übersetzung",
@ -706,7 +705,6 @@
"条件": "Zustand",
"指定人名翻译": "Übersetzung benannter Namen",
"专有名词翻译": "Übersetzung von geschützten Begriffen",
"VNR共享辞书": "VNR Shared Lexicon",
"自定义优化": "Kundenspezifische Optimierung",
"人名": "Name",
"游戏数据": "Spieldaten",

View File

@ -35,7 +35,6 @@
"搜索": "Search",
"显示游戏静音按钮": "Show Mute Game Button",
"動詞": "Verbs",
"共享辞书": "Shared Dictionary",
"注册网址": "Registration URL",
"显示帧率": "Display FPS",
"自动翻译": "Auto Translate",
@ -705,7 +704,6 @@
"条件": "condition",
"指定人名翻译": "Designated Name Translation",
"专有名词翻译": "Translation of proprietary terms",
"VNR共享辞书": "VNR Shared Lexicon",
"自定义优化": "Custom optimization",
"人名": "name",
"游戏数据": "Game data",

View File

@ -127,7 +127,6 @@
"图标": "Iconos",
"指示詞": "Instrucción",
"動詞": "Verbos",
"共享辞书": "Diccionario compartido",
"注册网址": "Sitio web de registro",
"显示帧率": "Muestra la tasa de fotogramas",
"游戏": "Juego",
@ -705,7 +704,6 @@
"条件": "Condiciones",
"指定人名翻译": "Traducción de nombre designado",
"专有名词翻译": "Traducción de términos propios",
"VNR共享辞书": "Diccionario compartido vnr",
"自定义优化": "Optimización personalizada",
"人名": "Nombre",
"游戏数据": "Datos del juego",

View File

@ -127,7 +127,6 @@
"图标": "Icônes",
"指示詞": "Mot indicateur",
"動詞": "Verbes",
"共享辞书": "Partager un dictionnaire",
"注册网址": "Site Web d'inscription",
"显示帧率": "Afficher le taux de trame",
"游戏": "Le jeu",
@ -705,7 +704,6 @@
"条件": "Conditions",
"指定人名翻译": "Nom de la personne désignée traduction",
"专有名词翻译": "Traduction de noms propres",
"VNR共享辞书": "VNR partager discours",
"自定义优化": "Optimisation personnalisée",
"人名": "Nom de la personne",
"游戏数据": "Données du jeu",

View File

@ -124,7 +124,6 @@
"图标": "icona",
"指示詞": "Parole dimostrative",
"動詞": "Verbi",
"共享辞书": "Dizionario condiviso",
"注册网址": "Sito web di registrazione",
"显示帧率": "Mostra frame rate",
"游戏": "gioco",
@ -705,7 +704,6 @@
"条件": "condizione",
"指定人名翻译": "Traduzione del nome designato",
"专有名词翻译": "Traduzione di termini proprietari",
"VNR共享辞书": "Lexicon condiviso VNR",
"自定义优化": "Ottimizzazione personalizzata",
"人名": "nome",
"游戏数据": "Dati di gioco",

View File

@ -127,7 +127,6 @@
"图标": "アイコン",
"指示詞": "指示語",
"動詞": "動詞",
"共享辞书": "辞書の共有",
"注册网址": "登録サイト",
"显示帧率": "フレームレートを表示",
"游戏": "ゲーム",
@ -705,7 +704,6 @@
"条件": "条件#ジョウケン#",
"指定人名翻译": "指定人名翻訳",
"专有名词翻译": "固有名詞の翻訳",
"VNR共享辞书": "VNR共有辞書",
"自定义优化": "カスタム最適化",
"人名": "人名",
"游戏数据": "ゲームデータ",

View File

@ -127,7 +127,6 @@
"图标": "아이콘",
"指示詞": "지시어",
"動詞": "동사",
"共享辞书": "사서를 공유하다",
"注册网址": "웹 주소 등록",
"显示帧率": "프레임 속도 표시",
"游戏": "게임",
@ -705,7 +704,6 @@
"条件": "조건",
"指定人名翻译": "사용자 이름 번역 지정",
"专有名词翻译": "고유명사 번역",
"VNR共享辞书": "VNR 공유 사서",
"自定义优化": "사용자 정의 최적화",
"人名": "인명",
"游戏数据": "게임 데이터",

View File

@ -431,7 +431,6 @@
"起始地址(hex)": "Startadres (hex)",
"说明": "uitleggen",
"处理": "handgreep",
"共享辞书": "Gedeeld woordenboek",
"助動詞": "Bijwerkwoord",
"选择文件": "Bestand selecteren",
"自动翻译": "Automatische vertaling",
@ -706,7 +705,6 @@
"条件": "conditie",
"指定人名翻译": "Vertaling van aangewezen naam",
"专有名词翻译": "Vertaling van eigendomstermen",
"VNR共享辞书": "VNR Shared Lexicon",
"自定义优化": "Aangepaste optimalisatie",
"人名": "naam",
"游戏数据": "Spelgegevens",

View File

@ -127,7 +127,6 @@
"图标": "Ikona",
"指示詞": "Słowa demonstracyjne",
"動詞": "Czasowniki",
"共享辞书": "Słownik współdzielony",
"注册网址": "Strona internetowa rejestracyjna",
"显示帧率": "Wyświetlanie częstotliwości klatek",
"游戏": "gra",
@ -705,7 +704,6 @@
"条件": "stan",
"指定人名翻译": "Tłumaczenie oznaczonej nazwy",
"专有名词翻译": "Tłumaczenie terminów własności",
"VNR共享辞书": "Wspólny leksykon VNR",
"自定义优化": "Optymalizacja niestandardowa",
"人名": "nazwa",
"游戏数据": "Dane gry",

View File

@ -431,7 +431,6 @@
"起始地址(hex)": "Endereço inicial (hex)",
"说明": "explicar",
"处理": "alça",
"共享辞书": "Dicionário Partilhado",
"助動詞": "Verbo auxiliar",
"选择文件": "Seleccionar o ficheiro",
"自动翻译": "Tradução automática",
@ -706,7 +705,6 @@
"条件": "condição",
"指定人名翻译": "Tradução de Nomes Designados",
"专有名词翻译": "Tradução de termos proprietários",
"VNR共享辞书": "Léxico Partilhado do VNR",
"自定义优化": "Otimização personalizada",
"人名": "nome",
"游戏数据": "Dados do jogo",

View File

@ -127,7 +127,6 @@
"图标": "Значки",
"指示詞": "указательное слово",
"動詞": "глагол",
"共享辞书": "общий словарь",
"注册网址": "сайт регистрации",
"显示帧率": "Частота кадров",
"游戏": "Игра",
@ -705,7 +704,6 @@
"条件": "Условия",
"指定人名翻译": "Имя назначенного переводчика",
"专有名词翻译": "Перевод терминов",
"VNR共享辞书": "VNR Обмен словарями",
"自定义优化": "Настройка оптимизации",
"人名": "Имя человека",
"游戏数据": "Игровые данные",

View File

@ -431,7 +431,6 @@
"起始地址(hex)": "Startadress (hex)",
"说明": "förklara",
"处理": "handtag",
"共享辞书": "Delad ordlista",
"助動詞": "Hjälpverb",
"选择文件": "Välj fil",
"自动翻译": "Automatisk översättning",
@ -706,7 +705,6 @@
"条件": "tillstånd",
"指定人名翻译": "Översättning av betecknat namn",
"专有名词翻译": "Översättning av egendomsbenämningar",
"VNR共享辞书": "Delad VNR- leksikon",
"自定义优化": "Anpassad optimering",
"人名": "namn",
"游戏数据": "Speldata",

View File

@ -430,7 +430,6 @@
"起始地址(hex)": "ที่อยู่เริ่มต้น (hex)",
"说明": "คำแนะนำ",
"处理": "การประมวลผล",
"共享辞书": "การแชร์สำนวน",
"助動詞": "คำกริยาช่วย",
"选择文件": "เลือกไฟล์",
"自动翻译": "การแปลอัตโนมัติ",
@ -705,7 +704,6 @@
"条件": "เงื่อนไข",
"指定人名翻译": "ระบุการแปลชื่อบุคคล",
"专有名词翻译": "การแปลคำนามที่เป็นกรรมสิทธิ์",
"VNR共享辞书": "VNR สำนวนที่ใช้ร่วมกัน",
"自定义优化": "การปรับแต่งให้เหมาะสม",
"人名": "ชื่อบุคคล",
"游戏数据": "ข้อมูลเกม",

View File

@ -127,7 +127,6 @@
"图标": "İşaretçi",
"指示詞": "Deixis",
"動詞": "Verbs",
"共享辞书": "Paylaşılan sözlük",
"注册网址": "Kayıt sitesi",
"显示帧率": "Çerçive hızını göster",
"游戏": "oyun",
@ -705,7 +704,6 @@
"条件": "durum",
"指定人名翻译": "Tasarlanmış İsim Çevirmesi",
"专有名词翻译": "Özel terimlerin çevirimi",
"VNR共享辞书": "VNR Paylaşılmış Lexicon",
"自定义优化": "Özel optimizasyon",
"人名": "isim",
"游戏数据": "Oyun verileri",

View File

@ -124,7 +124,6 @@
"图标": "Піктограма",
"指示詞": "Демонстративні слова",
"動詞": "Дієслова",
"共享辞书": "Спільний словник",
"注册网址": "Веб- сайт реєстрування",
"显示帧率": "Показувати швидкість рамок",
"游戏": "гра",
@ -705,7 +704,6 @@
"条件": "умови",
"指定人名翻译": "Переклад визначеної назви",
"专有名词翻译": "Переклад приєднаних термінів",
"VNR共享辞书": "Спільна ліксикона VNR",
"自定义优化": "Нетипова оптимізація",
"人名": "назва",
"游戏数据": "Дані гри",

View File

@ -127,7 +127,6 @@
"图标": "Biểu tượng",
"指示詞": "Từ chỉ dẫn",
"動詞": "Động từ",
"共享辞书": "Chia sẻ từ điển",
"注册网址": "Đăng ký địa chỉ web",
"显示帧率": "Hiện khung hình",
"游戏": "Trò chơi",
@ -705,7 +704,6 @@
"条件": "Điều kiện",
"指定人名翻译": "Name",
"专有名词翻译": "Bản dịch của proprietary noun",
"VNR共享辞书": "VNR chia sẻ thư từ",
"自定义优化": "Tối ưu hóa tùy chỉnh",
"人名": "Tên người",
"游戏数据": "Dữ liệu trò chơi",

View File

@ -432,7 +432,6 @@
"起始地址(hex)": "",
"说明": "",
"处理": "",
"共享辞书": "",
"助動詞": "",
"选择文件": "",
"自动翻译": "",
@ -708,7 +707,6 @@
"条件": "",
"指定人名翻译": "",
"专有名词翻译": "",
"VNR共享辞书": "",
"自定义优化": "",
"人名": "",
"游戏数据": "",

View File

@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 38)
set(VERSION_PATCH 14)
set(VERSION_MINOR 39)
set(VERSION_PATCH 0)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)