def main(): cd = sys.path[0] translation_path = os.path.join(cd, '../translation') lang_file = os.path.join(translation_path, 'lang/en.lang.csv') with open(lang_file, 'rt', encoding='utf-8') as fp: fp.readline() lines = [ LangLine.from_csv_line(line).origin for line in fp.readlines() ] pregame_file = os.path.join(translation_path, 'en_pregame.lua') client_file = os.path.join(translation_path, 'en_client.lua') ui_mgr = UiMgr() ui_mgr.load_lua_file(pregame_file) ui_mgr.load_lua_file(client_file) lines.extend([ui_line.origin for ui_line in ui_mgr.ui_lines.values()]) # 寻找累类似 <<1>> 的标记 tagger = re.compile(r'<<.*?>>') tags = set() # 搜索 去重 for line in lines: for match in tagger.finditer(line): tags.add(match.group(0)) # 排序输出 for tag in sorted(tags): print(tag)
def main(): cd = sys.path[0] translation_path = os.path.join(cd, '../translation') lang_file = os.path.join(translation_path, 'lang/en.lang.csv') with open(lang_file, 'rt', encoding='utf-8') as fp: fp.readline() lines = [LangLine.from_csv_line(line).origin for line in fp.readlines()] pregame_file = os.path.join(translation_path, 'en_pregame.lua') client_file = os.path.join(translation_path, 'en_client.lua') ui_mgr = UiMgr() ui_mgr.load_lua_file(pregame_file) ui_mgr.load_lua_file(client_file) lines.extend([ui_line.origin for ui_line in ui_mgr.ui_lines.values()]) # 寻找累类似 <<1>> 的标记 tagger = re.compile(r'<<.*?>>') tags = set() # 搜索 去重 for line in lines: for match in tagger.finditer(line): tags.add(match.group(0)) # 排序输出 for tag in sorted(tags): print(tag)
def test_translation(self): lang_line = LangLine.from_csv_line('"3427285","0","3","0","Laugh"') lang_line.set_translation('笑') self.assertEqual('"3427285","0","3","0","笑"', lang_line.to_csv_line())
def test_ctor_file_header(self): self.assertIsNone( LangLine.from_csv_line('"ID","Unknown","Index","Offset","Text"'))
def test_ctor(self): line = '"3427285","0","3","0","Laugh"' lang_line = LangLine.from_csv_line(line) self.assertEqual(line, lang_line.to_csv_line())
def test_ctor_file_header(self): self.assertIsNone(LangLine.from_csv_line('"ID","Unknown","Index","Offset","Text"'))