Fix #21 and added python script to create LocalizedStrings.ini from poeditor json files

This commit is contained in:
ChaosMarc 2020-05-22 19:18:59 +02:00
parent c982875959
commit e8dc732f2c
No known key found for this signature in database
GPG Key ID: 704A239985AEEAFA
2 changed files with 42 additions and 0 deletions

View 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()