Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a script that checks languages #70

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions sources/langcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
import os

from constants import CONST


def is_valid(langname, lang, englang):
missing = []

for key in englang:
if key not in lang:
missing.append(key)

if len(missing) == 0:
print("{} is complete".format(langname))
return True
else:
print("{} is missing these keys: {}".format(langname, missing))
return False


def main():
with open(os.path.join(CONST["LANG_DIR"], "en.json")) as enfile:
en = json.load(enfile)

errs = False

for lang in os.listdir(CONST["LANG_DIR"]):
if not lang.endswith('.json'):
continue

if lang == 'en.json':
continue

with open(os.path.join(CONST["LANG_DIR"], lang)) as langfile:
try:
if not is_valid(lang.split('.')[0], json.load(langfile), en):
errs = True
except json.decoder.JSONDecodeError:
errs = True
print("{} is not valid json".format(lang))

if errs:
exit(1)


if __name__ == '__main__':
main()