mirror of
https://gitlab.com/hashborgir/plugy.git
synced 2024-11-30 04:26:02 +00:00
Fix #21 and added python script to create LocalizedStrings.ini from poeditor json files
This commit is contained in:
parent
c982875959
commit
e8dc732f2c
Binary file not shown.
42
PlugYInstaller/PlugY/translations/json_to_ini.py
Normal file
42
PlugYInstaller/PlugY/translations/json_to_ini.py
Normal file
@ -0,0 +1,42 @@
|
||||
import os
|
||||
import json
|
||||
import codecs
|
||||
import shutil
|
||||
|
||||
files = ["ENG.json", "ESP.json", "DEU.json", "FRA.json", "POR.json", "ITA.json", "JPN.json", "KOR.json", "SIN.json", "CHI.json", "POL.json", "RUS.json"]
|
||||
translations = {}
|
||||
|
||||
for file in files:
|
||||
lang = os.path.splitext(file)[0]
|
||||
with open(file) as json_file:
|
||||
data = json.load(json_file)
|
||||
for key, value in data.items():
|
||||
if (key in translations):
|
||||
t = translations[key]
|
||||
else:
|
||||
t = {}
|
||||
t[lang] = value
|
||||
translations[key] = t
|
||||
json_file.close()
|
||||
|
||||
with codecs.open("../LocalizedStrings.ini", "w", encoding="utf16") as ini_file:
|
||||
ini_file.write(';UTF16\r\n')
|
||||
ini_file.write(';--------------------------------------------------------------------------------------;\r\n')
|
||||
ini_file.write('; ;\r\n')
|
||||
ini_file.write('; "PlugY, The Survival Kit" ;\r\n')
|
||||
ini_file.write('; Localized String File ;\r\n')
|
||||
ini_file.write('; ;\r\n')
|
||||
ini_file.write('; by Yohann Nicolas ;\r\n')
|
||||
ini_file.write('; ;\r\n')
|
||||
ini_file.write('; version 11.02 ;\r\n')
|
||||
ini_file.write('; ;\r\n')
|
||||
ini_file.write(';--------------------------------------------------------------------------------------;\r\n')
|
||||
ini_file.write('\r\n')
|
||||
|
||||
for key, langs in translations.items():
|
||||
ini_file.write("[{}]\r\n".format(key))
|
||||
for lang, value in langs.items():
|
||||
ini_file.write("{}={}\r\n".format(lang, value))
|
||||
ini_file.write("\r\n")
|
||||
|
||||
ini_file.close()
|
Loading…
Reference in New Issue
Block a user