1
0
Fork 0
akkoma-fe/src/i18n/prune

32 lines
669 B
Python
Executable File

#!/usr/bin/env python3
from glob import glob
import json
def prune(other, english):
if not isinstance(other, dict):
return other
pruned = {}
for key, value in other.items():
if key in english:
pruned[key] = prune(value, english[key])
return pruned
with open("en.json", "r", encoding="utf-8") as f:
english = json.load(f)
for file in glob("*.json"):
if file == "en.json":
continue
with open(file, "r") as f:
other = json.load(f)
pruned = prune(other, english)
with open(file, "w", encoding="utf-8") as f:
json.dump(pruned, f, indent=4, sort_keys=True, ensure_ascii=False)