pleroma-fe/src/i18n/prune
2022-08-04 08:40:01 +00:00

31 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)