Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
 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())
Пример #4
0
 def test_ctor_file_header(self):
     self.assertIsNone(
         LangLine.from_csv_line('"ID","Unknown","Index","Offset","Text"'))
Пример #5
0
 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())
Пример #6
0
 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())
Пример #7
0
 def test_ctor_file_header(self):
     self.assertIsNone(LangLine.from_csv_line('"ID","Unknown","Index","Offset","Text"'))
Пример #8
0
 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())