forked from Ranossy/plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate.py.bak
42 lines (33 loc) · 969 Bytes
/
translate.py.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*-coding:utf-8 -*-
#test
import os.path
import codecs
import sys
from langconv import *
print(sys.version)
print(sys.version_info)
# 转换繁体到简体
def T2S(line):
line = Converter('zh-hans').convert(line)
line.encode('utf-8')
return line
# 转换简体到繁体
def S2T(line):
line = Converter('zh-hant').convert(line)
line.encode('utf-8')
return line
def file_c2t(path, filename):
file = open(path + '\\' + filename, 'rt', encoding="ansi")
line = file.read()
line2 = S2T(line)
file2 = open(path + '\\' + filename.replace('zhcn', 'zhtw'), 'wt', encoding="utf-8")
file2.write(line2)
file.close()
file2.close()
rootdir = r'C:\JX3HD\bin\zhcn_hd\interface\LR_Plugin'
for parent, dirnames, filenames in os.walk(rootdir):
for filename in filenames:
if filename.find("zhcn") > -1 and filename.find("jx3dat") > -1:
print(parent, filename)
file_c2t(parent, filename)
#print("翻译完成")