diff --git a/converter.py b/converter.py index 94715da..9e1bea6 100644 --- a/converter.py +++ b/converter.py @@ -4,7 +4,8 @@ import json import re import time -from typing import Callable, Optional, List, Set +import inspect +from typing import Dict, List, Set from romajitable import to_kana as tk from pypinyin import Style, lazy_pinyin, load_phrases_dict @@ -23,8 +24,8 @@ jieba.load_userdict(str(P / "data" / "dict.txt")) # 初始化其他自定义数据 +fixed_zh_u = load_json("fixed_zh_universal") tone_to_ipa: Ldata = {"1": "˥", "2": "˧˥", "3": "˨˩˦", "4": "˥˩", "5": ""} # IPA声调 - rep_ja_kk: Ldata = load_json("rep_ja_kk") # 片假名替换修正 manyoganas_dict: Ldata = load_json("manyogana") # 万叶假名 @@ -75,21 +76,10 @@ def capitalize_titles(text: str) -> str: str: 转换结果 """ - def title_case_content(content: str) -> str: - """ - 将书名号中的内容首字母大写。 - - Args: - content (str): 书名号中的内容。 - - Returns: - str: 首字母大写后的书名号内容。 - """ - - return " ".join(word.capitalize() for word in content.split()) - return re.sub( - r"《(.*?)》", lambda match: f"《{title_case_content(match.group(1))}》", text + r"《(.*?)》", + lambda match: f"《{' '.join(word.capitalize() for word in match.group(1).split())}》", + text, ) @@ -102,7 +92,7 @@ def add_apostrophes(input_list: List[str], values: Set[str]) -> List[str]: values (Set[str]): 有效的拼写 Returns: - list: 处理结果 + List[str]: 处理结果 """ for i in range(1, len(input_list)): @@ -116,6 +106,21 @@ def add_apostrophes(input_list: List[str], values: Set[str]) -> List[str]: return input_list +def segment_str(text: str, auto_cut: bool = True) -> List[str]: + """ + 将字符串分词。 + + Args: + text (str): 需要转换的字符串 + auto_cut (bool, optional): 是否自动分词,默认为True + + Returns: + str: 转换结果 + """ + + return jieba.lcut(text) if auto_cut else text.split() + + def to_katakana(text: str) -> str: """ 将字符串中的英文转写为片假名。 @@ -141,35 +146,39 @@ def to_manyogana(text: str) -> str: str: 转换结果 """ - return "".join([manyoganas_dict.get(char, char) for char in to_katakana(text)]) + return "".join(manyoganas_dict.get(char, char) for char in to_katakana(text)) -def to_pinyin(text: str) -> str: +def to_pinyin(text: str, rep: Ldata, auto_cut: bool = True) -> str: """ 将字符串中的汉字转写为拼音,尝试遵循GB/T 16159-2012分词,词之间使用空格分开。 Args: text (str): 需要转换的字符串 + rep (Ldata): 需要替换格式的内容 + auto_cut (bool, optional): 是否自动分词,默认为True Returns: str: 转换结果 """ - seg_list: List[str] = jieba.lcut(text) + seg_list = segment_str(text, auto_cut) output_list: List[str] = [] for seg in seg_list: pinyin_list = lazy_pinyin(seg, style=Style.TONE) - # 处理隔音符号 - for i, py in enumerate(pinyin_list[1:], 1): - if py.startswith(finals): - pinyin_list[i] = f"'{py}" + pinyin_list = [ + ( + f"'{py}" + if i > 0 and py.startswith(finals) and pinyin_list[i - 1][-1].isalpha() + else py + ) + for i, py in enumerate(pinyin_list) + ] output_list.append("".join(pinyin_list)) - # 调整格式 - result = replace_multiple(" ".join(output_list), rep_zh) - - return capitalize_lines(capitalize_titles(result)) + result = " ".join(output_list) + return capitalize_lines(capitalize_titles(replace_multiple(result, rep))) def to_ipa(text: str) -> str: @@ -186,7 +195,7 @@ def to_ipa(text: str) -> str: pinyin_list = lazy_pinyin(text, style=Style.TONE3, neutral_tone_with_five=True) ipa_list = [ - f"{pinyin_to["ipa"].get(p[:-1], p[:-1])}{tone_to_ipa.get(p[-1], p[-1])}" + f"{pinyin_to['ipa'].get(p[:-1], p[:-1])}{tone_to_ipa.get(p[-1], p[-1])}" for p in pinyin_list ] return " ".join(ipa_list) @@ -206,44 +215,46 @@ def to_bopomofo(text: str) -> str: return " ".join(lazy_pinyin(text, style=Style.BOPOMOFO)) -def to_wadegiles(text: str) -> str: +def to_wadegiles(text: str, rep: Ldata, auto_cut: bool = True) -> str: """ 将字符串中的汉字转写为威妥玛拼音,单字之间使用连字符分开,词之间使用空格分开。 Args: text (str): 需要转换的字符串 + rep (Ldata): 需要替换格式的内容 + auto_cut (bool, optional): 是否自动分词,默认为True Returns: str: 转换结果 """ - seg_list: List[str] = jieba.lcut(text) + seg_list = segment_str(text, auto_cut) output_list: List[str] = [] for seg in seg_list: pinyin_list = lazy_pinyin(seg, style=Style.TONE3, neutral_tone_with_five=True) - gr_list = [pinyin_to["wadegiles"].get(p, p) for p in pinyin_list] - output_list.append("-".join(gr_list)) - - # 调整格式 - result = replace_multiple(" ".join(output_list), rep_zh) + wg_list = [pinyin_to["wadegiles"].get(p, p) for p in pinyin_list] + output_list.append("-".join(wg_list)) - return capitalize_lines(capitalize_titles(result)) + result = " ".join(output_list) + return capitalize_lines(capitalize_titles(replace_multiple(result, rep))) -def to_romatzyh(text: str) -> str: +def to_romatzyh(text: str, rep: Ldata, auto_cut: bool = True) -> str: """ 将字符串中的汉字转写为国语罗马字,词之间使用空格分开。 Args: text (str): 需要转换的字符串 + rep (Ldata): 需要替换格式的内容 + auto_cut (bool, optional): 是否自动分词,默认为True Returns: str: 转换结果 """ - seg_list: List[str] = jieba.lcut(text) - output_list: List[str] = [] + seg_list = segment_str(text, auto_cut) + output_list = [] for seg in seg_list: seg = seg.replace("不", "bu") @@ -251,23 +262,25 @@ def to_romatzyh(text: str) -> str: gr_list = [pinyin_to["romatzyh"].get(p, p) for p in pinyin_list] output_list.append("".join(add_apostrophes(gr_list, gr_values))) - result = replace_multiple(" ".join(output_list), rep_zh) # 调整格式 + result = " ".join(output_list) - return capitalize_lines(capitalize_titles(result)) + return capitalize_lines(capitalize_titles(replace_multiple(result, rep))) -def to_cyrillic(text: str) -> str: +def to_cyrillic(text: str, rep: Ldata, auto_cut: bool = True) -> str: """ - 将字符串中的汉字转写为西里尔字母,使用帕拉季音标体系,词之间使用空格分开。 + 将字符串中的汉字转写为西里尔字母,使用帕拉季音标体系。 Args: text (str): 需要转换的字符串 + rep (Ldata): 需要替换格式的内容 + auto_cut (bool, optional): 是否自动分词,默认为True Returns: str: 转换结果 """ - seg_list: List[str] = jieba.lcut(text) + seg_list = segment_str(text, auto_cut) output_list: List[str] = [] for seg in seg_list: @@ -275,59 +288,67 @@ def to_cyrillic(text: str) -> str: cy_list = [pinyin_to["cyrillic"].get(p, p) for p in pinyin_list] output_list.append("".join(add_apostrophes(cy_list, cy_values))) - result = replace_multiple(" ".join(output_list), rep_zh) # 调整格式 - - return capitalize_lines(capitalize_titles(result)) + result = " ".join(output_list) + return capitalize_lines(capitalize_titles(replace_multiple(result, rep))) -def to_xiaojing(text: str) -> str: +def to_xiaojing(text: str, rep: Ldata, auto_cut: bool = True) -> str: """ - 将字符串中的汉字转写为小儿经,单字之间使用零宽不连字(U+200C)分开,词之间使用空格分开。 + 将字符串中的汉字转写为小儿经,使用零宽不连字(U+200C)分开。 Args: text (str): 需要转换的字符串 + rep (Ldata): 需要替换格式的内容 + auto_cut (bool, optional): 是否自动分词,默认为True Returns: str: 转换结果 """ - seg_list: List[str] = jieba.lcut(text) - output_list: List[str] = [] - + seg_list = segment_str(text, auto_cut) + output_list = [] for seg in seg_list: pinyin_list = lazy_pinyin(seg) xj_list = [pinyin_to["xiaojing"].get(p, p) for p in pinyin_list] output_list.append("\u200c".join(xj_list)) - - return replace_multiple(" ".join(output_list), rep_zh) + return replace_multiple(" ".join(output_list), rep) -def save_to_json( - input_dict: Ldata, - output_file: str, - func: Callable[[str], str], - fix_dict: Optional[Ldata] = None, - output_folder: str = "output", -) -> None: - """ - 将生成的语言文件保存至JSON。 +def save_to_json(input_dict: Ldata, config: Dict) -> None: + """将生成的语言文件保存至JSON。 Args: input_dict (Ldata): 输入的数据 - output_file (str): 保存的文件名,无格式后缀 - func (Callable[[str], str]): 生成语言文件所用的函数 - fix_dict (Optional[Ldata], optional): 语言文件中需要修复的内容. 默认为None - output_folder (str, optional): 保存的文件夹,默认为“output” + config (Dict): 含有配置的字典 """ start_time = time.time() - full_file_name = f"{output_file}.json" - output_dict = {k: func(v) for k, v in input_dict.items()} - if fix_dict: - output_dict.update(fix_dict) - file_path = P / output_folder / full_file_name + + func = config["func"] + + auto_cut = config.get("auto_cut", True) + rep = config.get("rep", rep_zh) + + output_dict = {} + for k, v in input_dict.items(): + func_signature = inspect.signature(func) + kwargs = {} + if "auto_cut" in func_signature.parameters and auto_cut is not None: + kwargs["auto_cut"] = auto_cut + if "rep" in func_signature.parameters and rep is not None: + kwargs["rep"] = rep + output_dict[k] = func(v, **kwargs) + + output_dict.update(fixed_zh_u) + if config.get("fixed_dict"): + output_dict.update(config["fixed_dict"]) + file_path = ( + P / config.get("output_folder", "output") / f"{config['output_file']}.json" + ) with open(file_path, "w", encoding="utf-8") as j: json.dump(output_dict, j, indent=2, ensure_ascii=False) elapsed_time = time.time() - start_time size = f"{round(file_path.stat().st_size / 1024, 2)} KB" - print(f"已生成语言文件“{full_file_name}”,大小{size},耗时{elapsed_time:.2f} s。") + print( + f"已生成语言文件“{config['output_file']}.json”,大小{size},耗时{elapsed_time:.2f} s。" + ) diff --git a/fix_data.py b/fix_data.py index c679e41..0c51aec 100644 --- a/fix_data.py +++ b/fix_data.py @@ -1,149 +1,66 @@ # -*- encoding: utf-8 -*- """数据修复脚本""" -from typing import List -from pypinyin import Style, lazy_pinyin - -from base import ( - load_json, - pinyin_to, - gr_values, - cy_values, -) +from base import load_json from converter import ( save_to_json, - capitalize_lines, - capitalize_titles, - replace_multiple, - add_apostrophes, + to_pinyin, + to_wadegiles, + to_romatzyh, + to_cyrillic, + to_xiaojing, ) -rep_zh = {"!:(": "! :(", ",": ", "} - - -def to_pinyin(text: str) -> str: - """ - 将字符串中的汉字转写为拼音,尝试遵循GB/T 16159-2012分词,词之间使用空格分开。 - - Args: - text (str): 需要转换的字符串 - - Returns: - str: 转换结果 - """ - - seg_list: List[str] = text.split() - output_list: List[str] = [] - - for seg in seg_list: - pinyin_list = lazy_pinyin(seg, style=Style.TONE) - output_list.append("".join(pinyin_list)) - - # 调整格式 - result = replace_multiple(" ".join(output_list), rep_zh) - - return capitalize_lines(capitalize_titles(result)) - - -def to_wadegiles(text: str) -> str: - """ - 将字符串中的汉字转写为威妥玛拼音,单字之间使用连字符分开,词之间使用空格分开。 - - Args: - text (str): 需要转换的字符串 - - Returns: - str: 转换结果 - """ - - seg_list: List[str] = text.split() - output_list: List[str] = [] - - for seg in seg_list: - pinyin_list = lazy_pinyin(seg, style=Style.TONE3, neutral_tone_with_five=True) - gr_list = [pinyin_to["wadegiles"].get(p, p) for p in pinyin_list] - output_list.append("-".join(gr_list)) - - # 调整格式 - result = replace_multiple(" ".join(output_list), rep_zh) - - return capitalize_lines(capitalize_titles(result)) - - -def to_romatzyh(text: str) -> str: - """ - 将字符串中的汉字转写为国语罗马字,词之间使用空格分开。 - - Args: - text (str): 需要转换的字符串 - - Returns: - str: 转换结果 - """ - - seg_list: List[str] = text.split() - output_list: List[str] = [] - - for seg in seg_list: - seg = seg.replace("不", "bu") - pinyin_list = lazy_pinyin(seg, style=Style.TONE3, neutral_tone_with_five=True) - gr_list = [pinyin_to["romatzyh"].get(p, p) for p in pinyin_list] - output_list.append("".join(add_apostrophes(gr_list, gr_values))) - - result = replace_multiple(" ".join(output_list), rep_zh) # 调整格式 - - return capitalize_lines(capitalize_titles(result)) - - -def to_cyrillic(text: str) -> str: - """ - 将字符串中的汉字转写为西里尔字母,使用帕拉季音标体系,词之间使用空格分开。 - - Args: - text (str): 需要转换的字符串 - - Returns: - str: 转换结果 - """ - - seg_list: List[str] = text.split() - output_list: List[str] = [] - - for seg in seg_list: - pinyin_list = lazy_pinyin(seg) - cy_list = [pinyin_to["cyrillic"].get(p, p) for p in pinyin_list] - output_list.append("".join(add_apostrophes(cy_list, cy_values))) - - result = replace_multiple(" ".join(output_list), rep_zh) # 调整格式 - - return capitalize_lines(capitalize_titles(result)) - - -def to_xiaojing(text: str) -> str: - """ - 将字符串中的汉字转写为小儿经,单字之间使用零宽不连字(U+200C)分开,词之间使用空格分开。 - - Args: - text (str): 需要转换的字符串 - - Returns: - str: 转换结果 - """ - - seg_list: List[str] = text.split() - output_list: List[str] = [] - - for seg in seg_list: - pinyin_list = lazy_pinyin(seg) - xj_list = [pinyin_to["xiaojing"].get(p, p) for p in pinyin_list] - output_list.append("\u200c".join(xj_list)) - - return replace_multiple(" ".join(output_list), rep_zh) - +rep = {"!:(": "! :(", ",": ", "} fixed_zh_source = load_json("fixed_zh_source") -save_to_json(fixed_zh_source, "fixed_zh_py", to_pinyin, output_folder="data") -save_to_json(fixed_zh_source, "fixed_zh_wg", to_wadegiles, output_folder="data") -save_to_json(fixed_zh_source, "fixed_zh_gr", to_romatzyh, output_folder="data") -save_to_json(fixed_zh_source, "fixed_zh_cy", to_cyrillic, output_folder="data") -save_to_json(fixed_zh_source, "fixed_zh_xj", to_xiaojing, output_folder="data") +save_to_json( + fixed_zh_source, + { + "output_file": "fixed_zh_py", + "func": to_pinyin, + "output_folder": "data", + "auto_cut": False, + "rep": rep, + }, +) +save_to_json( + fixed_zh_source, + { + "output_file": "fixed_zh_wg", + "func": to_wadegiles, + "output_folder": "data", + "auto_cut": False, + "rep": rep, + }, +) +save_to_json( + fixed_zh_source, + { + "output_file": "fixed_zh_gr", + "func": to_romatzyh, + "output_folder": "data", + "auto_cut": False, + "rep": rep, + }, +) +save_to_json( + fixed_zh_source, + { + "output_file": "fixed_zh_cy", + "func": to_cyrillic, + "output_folder": "data", + "auto_cut": False, + "rep": rep, + }, +) +save_to_json( + fixed_zh_source, + { + "output_file": "fixed_zh_xj", + "func": to_xiaojing, + "output_folder": "data", + "auto_cut": False, + "rep": rep, + }, +) diff --git a/output/ja_kk.json b/output/ja_kk.json index 36499bd..9ffeaf9 100644 --- a/output/ja_kk.json +++ b/output/ja_kk.json @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "フ3・+・ス・=・ドゥンプ・ドユナミク・テッレス", "debug.gamemodes.error": "ウナブレ・ト・オペン・ガメ・モデ・スヰッチェル;・ノ・ペルミッシオン", "debug.gamemodes.help": "フ3・+・フ4・=・オペン・ガメ・モデ・スヰッチェル", - "debug.gamemodes.press_f4": "「・フ4・」", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s・ネクスト", "debug.help.help": "フ3・+・ク・=・ショワ・トヒス・リスト", "debug.help.message": "ケユ・ビンディングス:", @@ -4684,7 +4684,7 @@ "known_server_link.status": "スタツス", "known_server_link.support": "スッポルト", "known_server_link.website": "ヱブシテ", - "language.code": "en_us", + "language.code": "zho-Hans_CN", "language.name": "エングリスホ", "language.region": "ウニテド・スタテス", "lanServer.otherPlayers": "セッチングス・フォル・オトヘル・プライェルス", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "クリストッフェル・ゼッテルストランド", "painting.minecraft.sunflowers.title": "スンフロヱルス", "painting.minecraft.sunset.author": "クリストッフェル・ゼッテルストランド", - "painting.minecraft.sunset.title": "スンセト_デンセ", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "クリストッフェル・ゼッテルストランド", "painting.minecraft.tides.title": "チデス", "painting.minecraft.unpacked.author": "サラホ・ボエヴィング", diff --git a/output/ja_my.json b/output/ja_my.json index bde65ff..5293728 100644 --- a/output/ja_my.json +++ b/output/ja_my.json @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "不3・+・須・=・特宇尓不・特由奈三久・天川礼須", "debug.gamemodes.error": "宇奈夫礼・止・於部尓・賀女・毛代・須井川千江流;・乃・部流三川之於尓", "debug.gamemodes.help": "不3・+・不4・=・於部尓・賀女・毛代・須井川千江流", - "debug.gamemodes.press_f4": "「・不4・」", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s・祢久須止", "debug.help.help": "不3・+・久・=・之與和・止比須・利須止", "debug.help.message": "介由・眉尓代伊尓具須:", @@ -4684,7 +4684,7 @@ "known_server_link.status": "須多川須", "known_server_link.support": "須川保流止", "known_server_link.website": "恵夫之天", - "language.code": "en_us", + "language.code": "zho-Hans_CN", "language.name": "江尓具利須保", "language.region": "宇仁天特・須多天須", "lanServer.otherPlayers": "世川千尓具須・不於流・於止部流・不良伊江流須", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "久利須止川不江流・是川天流須止良尓特", "painting.minecraft.sunflowers.title": "須尓不呂恵流須", "painting.minecraft.sunset.author": "久利須止川不江流・是川天流須止良尓特", - "painting.minecraft.sunset.title": "須尓世止_代尓世", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "久利須止川不江流・是川天流須止良尓特", "painting.minecraft.tides.title": "千代須", "painting.minecraft.unpacked.author": "散良保・番江无伊尓具", diff --git a/output/zh_cy.json b/output/zh_cy.json index 2d70bda..df707a6 100644 --- a/output/zh_cy.json +++ b/output/zh_cy.json @@ -248,7 +248,7 @@ "advancements.nether.use_lodestone.description": "Дуй чжэ цыши шиюн чжинаньчжэнь", "advancements.nether.use_lodestone.title": "Тянья гунцыши", "advancements.progress": "%s/%s", - "advancements.sad_label": ": (", + "advancements.sad_label": ":(", "advancements.story.cure_zombie_villager.description": "Жохуа бин чжиляо имин цзянши цуньминь", "advancements.story.cure_zombie_villager.title": "Цзянши кэ ишэн", "advancements.story.deflect_arrow.description": "Юн дуньпай фаньтань игэ таньшэ у", @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "F3 + S = чжуаньчу дунтай вэньли", "debug.gamemodes.error": "Ни мэйю цюаньсянь дакай юси моши цехуаньци", "debug.gamemodes.help": "F3 + F4 = дакай юси моши цехуаньци", - "debug.gamemodes.press_f4": "[F4]", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s ся игэ", "debug.help.help": "F3 + Q = сяньши цы лебяо", "debug.help.message": "Аньцзянь шэчжи: ", @@ -4693,7 +4693,7 @@ "lanServer.scanning": "Чжэнцзай ни дэ бэньдиванло чжун сюньчжао юси", "lanServer.start": "Чуанцзянь цзюйюйван шицзе", "lanServer.title": "Цзюйюйван шицзе", - "language.code": "Zho - Hans_CN", + "language.code": "zho-Hans_CN", "language.name": "Цзяньтичжунвэнь", "language.region": "Чжунго далу", "lectern.take_book": "Цюйшу", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand", "painting.minecraft.sunflowers.title": "Sunflowers", "painting.minecraft.sunset.author": "Kristoffer Zetterstrand", - "painting.minecraft.sunset.title": "Sunset_dense", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "Kristoffer Zetterstrand", "painting.minecraft.tides.title": "Tides", "painting.minecraft.unpacked.author": "Sarah Boeving", diff --git a/output/zh_gr.json b/output/zh_gr.json index dac1a60..2a8ad12 100644 --- a/output/zh_gr.json +++ b/output/zh_gr.json @@ -248,7 +248,7 @@ "advancements.nether.use_lodestone.description": "Duey .je tsyrshyr shyyyonq jyynanjen", "advancements.nether.use_lodestone.title": "Tianya gonqtsyyshyr", "advancements.progress": "%s/%s", - "advancements.sad_label": ": (", + "advancements.sad_label": ":(", "advancements.story.cure_zombie_villager.description": "Ruohhuah binq jyhliau iming jiangshy tsuenmin", "advancements.story.cure_zombie_villager.title": "Jiangshy ke isheng", "advancements.story.deflect_arrow.description": "Yonq duennpair faantarn yigeh tarnsheh wuh", @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "F3 + S = joanchuu donqtay wenlii", "debug.gamemodes.error": "Nii meiyeou chyuanshiann daakai youshih moshyh chiehuannchih", "debug.gamemodes.help": "F3 + F4 = daakai youshih moshyh chiehuannchih", - "debug.gamemodes.press_f4": "[F4]", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s shiah yigeh", "debug.help.help": "F3 + Q = sheanshyh tsyy liehbeau", "debug.help.message": "Annjiann shehjyh: ", @@ -4693,7 +4693,7 @@ "lanServer.scanning": "Jenqtzay nii .de beendihwoangluoh jong shyunjao youshih", "lanServer.start": "Chuanqjiann jyuyuhwoang shyhjieh", "lanServer.title": "Jyuyuhwoang shyhjieh", - "language.code": "Zho - Hans_CN", + "language.code": "zho-Hans_CN", "language.name": "Jeantiijongwen", "language.region": "Jonggwo dahluh", "lectern.take_book": "Cheushu", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand", "painting.minecraft.sunflowers.title": "Sunflowers", "painting.minecraft.sunset.author": "Kristoffer Zetterstrand", - "painting.minecraft.sunset.title": "Sunset_dense", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "Kristoffer Zetterstrand", "painting.minecraft.tides.title": "Tides", "painting.minecraft.unpacked.author": "Sarah Boeving", diff --git a/output/zh_py.json b/output/zh_py.json index e9a7b8f..4175dda 100644 --- a/output/zh_py.json +++ b/output/zh_py.json @@ -248,7 +248,7 @@ "advancements.nether.use_lodestone.description": "Duì zhe císhí shǐyòng zhǐnánzhēn", "advancements.nether.use_lodestone.title": "Tiānyá gòngcǐshí", "advancements.progress": "%s/%s", - "advancements.sad_label": ": (", + "advancements.sad_label": ":(", "advancements.story.cure_zombie_villager.description": "Ruòhuà bìng zhìliáo yīmíng jiāngshī cūnmín", "advancements.story.cure_zombie_villager.title": "Jiāngshī kē yīshēng", "advancements.story.deflect_arrow.description": "Yòng dùnpái fǎntán yígè tánshè wù", @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "F3 + S = zhuǎnchǔ dòngtài wénlǐ", "debug.gamemodes.error": "Nǐ méiyǒu quánxiàn dǎkāi yóuxì móshì qiēhuànqì", "debug.gamemodes.help": "F3 + F4 = dǎkāi yóuxì móshì qiēhuànqì", - "debug.gamemodes.press_f4": "[F4]", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s xià yígè", "debug.help.help": "F3 + Q = xiǎnshì cǐ lièbiǎo", "debug.help.message": "Ànjiàn shèzhì: ", @@ -4693,7 +4693,7 @@ "lanServer.scanning": "Zhèngzài nǐ de běndìwǎngluò zhōng xúnzhǎo yóuxì", "lanServer.start": "Chuàngjiàn júyùwǎng shìjiè", "lanServer.title": "Júyùwǎng shìjiè", - "language.code": "Zho - Hans_CN", + "language.code": "zho-Hans_CN", "language.name": "Jiǎntǐzhōngwén", "language.region": "Zhōngguó dàlù", "lectern.take_book": "Qǔshū", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand", "painting.minecraft.sunflowers.title": "Sunflowers", "painting.minecraft.sunset.author": "Kristoffer Zetterstrand", - "painting.minecraft.sunset.title": "Sunset_dense", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "Kristoffer Zetterstrand", "painting.minecraft.tides.title": "Tides", "painting.minecraft.unpacked.author": "Sarah Boeving", diff --git a/output/zh_wg.json b/output/zh_wg.json index b9f8e62..94fc3fb 100644 --- a/output/zh_wg.json +++ b/output/zh_wg.json @@ -248,7 +248,7 @@ "advancements.nether.use_lodestone.description": "Tui⁴ che⁵ tz'u²-shih² shih³-yung⁴ chih³-nan²-chen¹", "advancements.nether.use_lodestone.title": "T'ien¹-ya² kung⁴-tz'u³-shih²", "advancements.progress": "%s/%s", - "advancements.sad_label": ": (", + "advancements.sad_label": ":(", "advancements.story.cure_zombie_villager.description": "Jo⁴-hua⁴ ping⁴ chih⁴-liao² i¹-ming² chiang¹-shih¹ ts'un¹-min²", "advancements.story.cure_zombie_villager.title": "Chiang¹-shih¹ k'o¹ i¹-sheng¹", "advancements.story.deflect_arrow.description": "Yung⁴ tun⁴-p'ai² fan³-t'an² i²-ko⁴ t'an²-she⁴ wu⁴", @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "F3 + S = chuan³-ch'u³ tung⁴-t'ai⁴ wen²-li³", "debug.gamemodes.error": "Ni³ mei²-yu³ ch'üan²-hsien⁴ ta³-k'ai¹ yu²-hsi⁴ mo²-shih⁴ ch'ieh¹-huan⁴-ch'i⁴", "debug.gamemodes.help": "F3 + F4 = ta³-k'ai¹ yu²-hsi⁴ mo²-shih⁴ ch'ieh¹-huan⁴-ch'i⁴", - "debug.gamemodes.press_f4": "[F4]", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s hsia⁴ i²-ko⁴", "debug.help.help": "F3 + Q = hsien³-shih⁴ tz'u³ lieh⁴-piao³", "debug.help.message": "An⁴-chien⁴ she⁴-chih⁴: ", @@ -4693,7 +4693,7 @@ "lanServer.scanning": "Cheng⁴-tsai⁴ ni³ te⁵ pen³-ti⁴-wang³-lo⁴ chung¹ hsün²-chao³ yu²-hsi⁴", "lanServer.start": "Ch'uang⁴-chien⁴ chü²-yü⁴-wang³ shih⁴-chieh⁴", "lanServer.title": "Chü²-yü⁴-wang³ shih⁴-chieh⁴", - "language.code": "Zho - Hans_CN", + "language.code": "zho-Hans_CN", "language.name": "Chien³-t'i³-chung¹-wen²", "language.region": "Chung¹-kuo² ta⁴-lu⁴", "lectern.take_book": "Ch'ü³-shu¹", @@ -5547,7 +5547,7 @@ "painting.minecraft.sunflowers.author": "Kristoffer Zetterstrand", "painting.minecraft.sunflowers.title": "Sunflowers", "painting.minecraft.sunset.author": "Kristoffer Zetterstrand", - "painting.minecraft.sunset.title": "Sunset_dense", + "painting.minecraft.sunset.title": "sunset_dense", "painting.minecraft.tides.author": "Kristoffer Zetterstrand", "painting.minecraft.tides.title": "Tides", "painting.minecraft.unpacked.author": "Sarah Boeving", diff --git a/output/zh_xj.json b/output/zh_xj.json index 933069b..da9e7b3 100644 --- a/output/zh_xj.json +++ b/output/zh_xj.json @@ -248,7 +248,7 @@ "advancements.nether.use_lodestone.description": "دُوِ جَ ڞِ‌شِ شِ‌یٌ جِ‌نًا‌جٍ", "advancements.nether.use_lodestone.title": "تِیًا‌یَا قْو‌ڞِ‌شِ", "advancements.progress": "%s/%s", - "advancements.sad_label": ": (", + "advancements.sad_label": ":(", "advancements.story.cure_zombie_villager.description": "رُوَ‌خُوَا بِیٍٔ جِ‌لِیَوْ ءِ‌مِیٍٔ ݣِیَانْ‌شِ ڞٌ‌مٍ", "advancements.story.cure_zombie_villager.title": "ݣِیَانْ‌شِ کْ ءِ‌شٍْ", "advancements.story.deflect_arrow.description": "یٌ دٌ‌پَیْ فًا‌تًا ءِ‌قْ تًا‌شَ وُ", @@ -3138,7 +3138,7 @@ "debug.dump_dynamic_textures.help": "F3 + S = جُوًا‌چُ دْو‌تَیْ وٌ‌لِ", "debug.gamemodes.error": "نِ مُوِ‌یُوْ کِیُوًا‌ثِیًا دَا‌کَیْ یُوْ‌ثِ مُوَ‌شِ کِیَ‌خُوًا‌کِ", "debug.gamemodes.help": "F3 + F4 = دَا‌کَیْ یُوْ‌ثِ مُوَ‌شِ کِیَ‌خُوًا‌کِ", - "debug.gamemodes.press_f4": "[F4]", + "debug.gamemodes.press_f4": "[ F4 ]", "debug.gamemodes.select_next": "%s ثِیَا ءِ‌قْ", "debug.help.help": "F3 + Q = ثِیًا‌شِ ڞِ لِیَ‌بِیَوْ", "debug.help.message": "اً‌ݣِیًا شَ‌جِ: ", @@ -4693,7 +4693,7 @@ "lanServer.scanning": "جٍْ‌زَیْ نِ دْ بٌ‌دِ‌وَانْ‌لُوَ جْو ثٌ‌جَوْ یُوْ‌ثِ", "lanServer.start": "چُوَانْ‌ݣِیًا ݣِیُوِ‌یُوِ‌وَانْ شِ‌ݣِیَ", "lanServer.title": "ݣِیُوِ‌یُوِ‌وَانْ شِ‌ݣِیَ", - "language.code": "zho - Hans_CN", + "language.code": "zho-Hans_CN", "language.name": "ݣِیًا‌تِ‌جْو‌وٌ", "language.region": "جْو‌قُوَ دَا‌لُ", "lectern.take_book": "کِیُوِ‌شُ", diff --git a/pack.py b/pack.py index df6374e..eb8276d 100644 --- a/pack.py +++ b/pack.py @@ -26,15 +26,42 @@ def main() -> None: # 生成语言文件 main_start_time = time.time() - save_to_json(data["en_us"], "ja_kk", to_katakana) - save_to_json(data["en_us"], "ja_my", to_manyogana) - save_to_json(data["zh_cn"], "zh_py", to_pinyin, fixed_zh["zh_py"]) - save_to_json(data["zh_cn"], "zh_ipa", to_ipa) - save_to_json(data["zh_cn"], "zh_bpmf", to_bopomofo) - save_to_json(data["zh_cn"], "zh_wg", to_wadegiles, fixed_zh["zh_wg"]) - save_to_json(data["zh_cn"], "zh_gr", to_romatzyh, fixed_zh["zh_gr"]) - save_to_json(data["zh_cn"], "zh_cy", to_cyrillic, fixed_zh["zh_cy"]) - save_to_json(data["zh_cn"], "zh_xj", to_xiaojing, fixed_zh["zh_xj"]) + save_to_json( + data["en_us"], + {"output_file": "ja_kk", "func": to_katakana}, + ) + save_to_json( + data["en_us"], + {"output_file": "ja_my", "func": to_manyogana}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_py", "func": to_pinyin, "fixed_dict": fixed_zh["zh_py"]}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_ipa", "func": to_ipa}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_bpmf", "func": to_bopomofo}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_wg", "func": to_wadegiles, "fixed_dict": fixed_zh["zh_wg"]}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_gr", "func": to_romatzyh, "fixed_dict": fixed_zh["zh_gr"]}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_cy", "func": to_cyrillic, "fixed_dict": fixed_zh["zh_cy"]}, + ) + save_to_json( + data["zh_cn"], + {"output_file": "zh_xj", "func": to_xiaojing, "fixed_dict": fixed_zh["zh_xj"]}, + ) main_elapsed_time = time.time() - main_start_time print(f"\n语言文件生成完毕,共耗时{main_elapsed_time:.2f} s。")