forked from JohnFranklin523/China-Set-Trains
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstr-csv.py
36 lines (28 loc) · 1.03 KB
/
str-csv.py
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
import re, csv, os
strs = []
with open('docs/str.csv', mode='r', newline='', encoding='utf-8-sig') as f:
reader = csv.reader(f)
for row in reader:
strs.append(row)
print(row)
if not os.path.exists("lang/"):
os.makedirs("lang/")
with open("lang/english.lng", 'w', encoding='utf-8') as f:
f.write("##grflangid 0x01"+"\n")
for i in range(len(strs)):
if strs[i][1] == "":
f.write(strs[i][0]+"\n")
else:
f.write(f"{strs[i][0]:48} {":"+strs[i][1]:<10}\n")
def other_lang_generate(lang_name, lang_row, lang_code):
with open("lang/"+lang_name+".lng", 'w', encoding='utf-8') as f:
f.write("##grflangid "+lang_code+"\n")
for i in range(len(strs)):
if strs[i][lang_row] == "":
if strs[i][1] == "":
f.write(strs[i][0]+"\n")
else:
pass
else:
f.write(f"{strs[i][0]:48} {":"+strs[i][2]:<10}\n")
other_lang_generate("simplified_chinese", 2, "0x56")