-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstr-csv.py
43 lines (33 loc) · 1.11 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
37
38
39
40
41
42
43
import csv
import os
import sys
try:
path = sys.argv[1]
except:
print("Please input the path of the csv file.")
strs = []
with open(path, mode="r", newline="", encoding="utf-8") as f:
reader = csv.reader(f)
for row in reader:
strs.append(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")