|
@ -27,23 +27,20 @@ for folder, dirs, files in os.walk(rootdir): |
|
|
error = True |
|
|
error = True |
|
|
print(f'TRANSLATION ERROR: {string}') |
|
|
print(f'TRANSLATION ERROR: {string}') |
|
|
missing_keys[string] = '' |
|
|
missing_keys[string] = '' |
|
|
en[string] = string # Add the missing key to the dictionary with an empty value |
|
|
print(f"Adding '{string}'") |
|
|
|
|
|
en[string] = string # Add the missing key to the dictionary |
|
|
elif string in unused_keys: |
|
|
elif string in unused_keys: |
|
|
unused_keys.remove(string) |
|
|
unused_keys.remove(string) |
|
|
|
|
|
|
|
|
# If there are missing keys, dump the updated dictionary back into the json file |
|
|
# If there are missing keys, dump the updated dictionary back into the json file |
|
|
if error: |
|
|
if error or unused_keys: |
|
|
print(json.dumps(missing_keys, indent=3)) |
|
|
# Remove unused keys |
|
|
with open('i18n/en.json', 'w') as f: |
|
|
if unused_keys: |
|
|
json.dump(en, f, indent=3) |
|
|
for key in unused_keys: |
|
|
exit(1) |
|
|
print(f"Removing '{key}'") |
|
|
|
|
|
del en[key] |
|
|
# If there are unused keys, print them |
|
|
else: |
|
|
# TODO: Do something useful? |
|
|
print("No unused keys found.") |
|
|
if unused_keys: |
|
|
|
|
|
print("UNUSED KEYS:") |
|
|
|
|
|
for key in unused_keys: |
|
|
|
|
|
print(key) |
|
|
|
|
|
else: |
|
|
|
|
|
print("No unused keys found.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open('i18n/en.json', 'w') as f: |
|
|
|
|
|
json.dump(en, f, indent=3) |
|
|