mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
Fix Sakura Dict of CHT (#976)
* fix sakura dict cht to chs * add zhhant, zhhans and fix dict
This commit is contained in:
parent
835b63a250
commit
846253f861
@ -52,8 +52,13 @@ class TS(basetrans):
|
||||
gpt_dict_text_list = []
|
||||
for gpt in gpt_dict:
|
||||
src = gpt["src"]
|
||||
dst = gpt["dst"]
|
||||
info = gpt["info"] if "info" in gpt.keys() else None
|
||||
if self.needzhconv:
|
||||
dst = zhconv.convert(gpt["dst"], "zh-hans")
|
||||
info = zhconv.convert(gpt["info"], "zh-hans") if "info" in gpt.keys() else None
|
||||
else:
|
||||
dst = gpt["dst"]
|
||||
info = gpt["info"] if "info" in gpt.keys() else None
|
||||
|
||||
if info:
|
||||
single = f"{src}->{dst} #{info}"
|
||||
else:
|
||||
@ -106,8 +111,6 @@ class TS(basetrans):
|
||||
content = ""
|
||||
|
||||
gpt_dict_raw_text = self.make_gpt_dict_text(gpt_dict)
|
||||
if self.needzhconv:
|
||||
gpt_dict_raw_text = zhconv.convert(gpt_dict_raw_text, "zh-cn")
|
||||
content += "根据以下术语表(可以为空):\n" + gpt_dict_raw_text + "\n\n"
|
||||
|
||||
content += (
|
||||
|
@ -8,6 +8,8 @@ dict_zhcn = None
|
||||
dict_zhsg = None
|
||||
dict_zhtw = None
|
||||
dict_zhhk = None
|
||||
dict_zhhans = None
|
||||
dict_zhhant = None
|
||||
pfsdict = {}
|
||||
|
||||
|
||||
@ -30,7 +32,7 @@ def getdict(locale):
|
||||
Generate or get convertion dict cache for certain locale.
|
||||
Dictionaries are loaded on demand.
|
||||
"""
|
||||
global zhcdicts, dict_zhcn, dict_zhsg, dict_zhtw, dict_zhhk, pfsdict
|
||||
global zhcdicts, dict_zhcn, dict_zhsg, dict_zhtw, dict_zhhk, dict_zhhans, dict_zhhant, pfsdict
|
||||
if zhcdicts is None:
|
||||
loaddict(DICTIONARY)
|
||||
if locale == "zh-cn":
|
||||
@ -47,6 +49,18 @@ def getdict(locale):
|
||||
dict_zhtw = zhcdicts["zh2Hant"].copy()
|
||||
dict_zhtw.update(zhcdicts["zh2TW"])
|
||||
got = dict_zhtw
|
||||
elif locale == "zh-hans":
|
||||
if dict_zhhans:
|
||||
got = dict_zhhans
|
||||
else:
|
||||
dict_zhhans = zhcdicts["zh2Hans"].copy()
|
||||
got = dict_zhhans
|
||||
elif locale == "zh-hant":
|
||||
if dict_zhhant:
|
||||
got = dict_zhhant
|
||||
else:
|
||||
dict_zhtw = zhcdicts["zh2Hant"].copy()
|
||||
got = dict_zhhant
|
||||
|
||||
if locale not in pfsdict:
|
||||
pfsdict[locale] = getpfset(got)
|
||||
|
Loading…
x
Reference in New Issue
Block a user