Prune i18n files (#110)
Reviewed-on: https://akkoma.dev/AkkomaGang/pleroma-fe/pulls/110
This commit is contained in:
parent
dfcc91c8c6
commit
2e92aaaaa3
34 changed files with 11372 additions and 11865 deletions
31
src/i18n/prune
Executable file
31
src/i18n/prune
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/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)
|
Loading…
Add table
Add a link
Reference in a new issue