diff --git a/LunaTranslator/LunaTranslator/myutils/commonbase.py b/LunaTranslator/LunaTranslator/myutils/commonbase.py index dc012681..0d3edc24 100644 --- a/LunaTranslator/LunaTranslator/myutils/commonbase.py +++ b/LunaTranslator/LunaTranslator/myutils/commonbase.py @@ -37,11 +37,11 @@ class commonbase: return self.langmap_.get(self.srclang_1, "") @property - def srclang_1(self): + def srclang_1(self) -> str: return getlangsrc() @property - def tgtlang_1(self): + def tgtlang_1(self) -> str: return getlangtgt() @property diff --git a/LunaTranslator/LunaTranslator/translator/deepl.py b/LunaTranslator/LunaTranslator/translator/deepl.py index 71761b4a..a9240a3a 100644 --- a/LunaTranslator/LunaTranslator/translator/deepl.py +++ b/LunaTranslator/LunaTranslator/translator/deepl.py @@ -55,10 +55,17 @@ def initDeepLXData(sourceLang: str, targetLang: str): class TS(basetrans): - def langmap(self): - x = {_: _.upper() for _ in [_["code"] for _ in static_data["lang_list_all"]]} - x.pop("cht") - return x # {"zh":"ZH","ja":"JA","en":"EN","es":"ES","fr":"FR","ru":"RU"} + @property + def srclang(self): + if self.srclang_1 == "cht": + return "ZH" + return self.srclang_1.upper() + + @property + def tgtlang(self): + if self.tgtlang_1 == "cht": + return "ZH-HANT" + return self.tgtlang_1.upper() def translate(self, translateText): if self.config["usewhich"] == 0: diff --git a/LunaTranslator/LunaTranslator/translator/deepl_dev.py b/LunaTranslator/LunaTranslator/translator/deepl_dev.py index e773616e..8cc29b33 100644 --- a/LunaTranslator/LunaTranslator/translator/deepl_dev.py +++ b/LunaTranslator/LunaTranslator/translator/deepl_dev.py @@ -5,6 +5,18 @@ from translator.basetranslator_dev import basetransdev class TS(basetransdev): target_url = "https://www.deepl.com/en/translator" + @property + def srclang(self): + if self.srclang_1 == "cht": + return "zh" + return self.srclang_1.upper() + + @property + def tgtlang(self): + if self.tgtlang_1 == "cht": + return "zh-hant" + return self.tgtlang_1 + def translate(self, content): self.Page_navigate( "https://www.deepl.com/en/translator#{}/{}/{}".format( diff --git a/LunaTranslator/LunaTranslator/translator/deeplapi-free.py b/LunaTranslator/LunaTranslator/translator/deeplapi-free.py index 06a82ad1..bd0f85b1 100644 --- a/LunaTranslator/LunaTranslator/translator/deeplapi-free.py +++ b/LunaTranslator/LunaTranslator/translator/deeplapi-free.py @@ -4,10 +4,18 @@ from translator.basetranslator import basetrans class TS(basetrans): - def langmap(self): - x = {_: _.upper() for _ in [_["code"] for _ in static_data["lang_list_all"]]} - x.pop("cht") - return x + + @property + def srclang(self): + if self.srclang_1 == "cht": + return "ZH" + return self.srclang_1.upper() + + @property + def tgtlang(self): + if self.tgtlang_1 == "cht": + return "ZH-HANT" + return self.tgtlang_1.upper() def translate(self, query): if self.config["usewhich"] == 0: