WikiWiki-Translation/convert.py
2023-09-10 09:39:10 +09:00

25 lines
854 B
Python

import os
import json
languages = ["ja","en","ru","ai","nm"]
def convertForPontoon():
for lang in languages:
for root, dirs, files in os.walk(top=f'./{lang}/'):
for file in files:
if not file.lower().endswith(('.json')):
continue
filePath = os.path.join(root, file)
print(f'filePath = {filePath}')
with open(filePath) as f:
data = json.load(f)
data["@metadata"] = json.dumps(data["@metadata"], ensure_ascii=False)
with open(filePath,"w") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
os.rename(filePath, os.path.dirname(filePath) + "/i18n.json")
return
def convertForMediaWiki():
return
if __name__ == "__main__":
convertForPontoon()