1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-04-14 14:53:11 +00:00

Fix/update language checker script

- Update location of the generated language file to point to common
   rather than Fabric.
 - Remove usage of OrderedDict, as dicts are ordered on recent versions
   of Python.
This commit is contained in:
Jonathan Coates 2024-07-24 19:28:20 +01:00
parent 5926b6c994
commit 4bfb9ac323
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

@ -17,12 +17,11 @@ ensure language files are mostly correct.
import json
import pathlib
from collections import OrderedDict
root = pathlib.Path("projects/common/src/main/resources/assets/computercraft/lang")
with open("projects/fabric/src/generated/resources/assets/computercraft/lang/en_us.json", encoding="utf-8") as file:
en_us = json.load(file, object_hook=OrderedDict)
with open("projects/common/src/generated/resources/assets/computercraft/lang/en_us.json", encoding="utf-8") as file:
en_us = json.load(file)
for path in root.glob("*.json"):
if path.name == "en_us.json":
@ -31,7 +30,7 @@ for path in root.glob("*.json"):
with path.open(encoding="utf-8") as file:
lang = json.load(file)
out = OrderedDict()
out = {}
missing = 0
for k in en_us.keys():
if k not in lang:
@ -46,4 +45,6 @@ for path in root.glob("*.json"):
file.write("\n")
if missing > 0:
print("{} has {} missing translations.".format(path.name, missing))
print("{} has {} missing translations. {:.2f}% complete".format(path.name, missing, len(out) / len(en_us) * 100))
else:
print("{} is complete".format(path.name))