Skip to content

Commit 24aeaaf

Browse files
committed
fix(translator): fix encoding on opening csv file and json saving output
1 parent 7c94bde commit 24aeaaf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _translate(self, args: list[str]) -> None:
111111
__datas = list[str]([])
112112
__regions = dict({})
113113

114-
with open(f"{__projectPath}/{args[0]}.csv", 'r', newline='') as file:
114+
with open(f"{__projectPath}/{args[0]}.csv", 'r', encoding=self.__cfg.getEncoding(), newline='') as file:
115115
print(f"{Icons.play}Reading CSV file and load translation ...")
116116
lines = DictReader(file, delimiter=',')
117117

@@ -137,13 +137,13 @@ def _translate(self, args: list[str]) -> None:
137137

138138
print(f"{Icons.play}Writing new regions json files ...")
139139

140-
for key in __regions:
140+
for key in set(__regions):
141141
__regionPath = abspath(f"{__projectPath}/{key}.json")
142142

143143
try:
144144
print(f'{Icons.play}WRITTING "{__regionPath}" [ {Colors.yellow}...{Colors.end} ]', end="\r")
145145

146-
with open(__regionPath, 'w') as regionFile:
146+
with open(__regionPath, 'w', encoding=self.__cfg.getEncoding()) as regionFile:
147147
string = str(dumps(__regions[key], indent=2, sort_keys=True))
148148
regionFile.write(string)
149149

0 commit comments

Comments
 (0)