From 0ad5b0dabff91b94ca2747503d8aa04de336dc92 Mon Sep 17 00:00:00 2001 From: flameshikari Date: Thu, 29 Feb 2024 16:00:34 +0500 Subject: [PATCH] update check_missing_lines.py --- utils/check_missing_lines.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utils/check_missing_lines.py b/utils/check_missing_lines.py index f4f8d09..b1695e0 100644 --- a/utils/check_missing_lines.py +++ b/utils/check_missing_lines.py @@ -4,9 +4,14 @@ import urllib.request workdir = os.path.abspath(os.path.dirname(__file__)) +def workdir(path): + basepath = os.path.abspath(os.path.dirname(__file__)) + abspath = os.path.abspath(basepath + '/' + path) + return abspath + en_json_path = 'https://github.com/outline/outline/raw/main/shared/i18n/locales/en_US/translation.json' -ru_json_path = os.path.abspath(workdir + '/../shared/i18n/locales/ru_RU/translation.json') -merged_json_path = os.path.abspath(workdir + '/merged.json') +ru_json_path = workdir('../shared/i18n/locales/ru_RU/translation.json') +merged_json_path = workdir('merged.json') missing_lines = {} merged_json = {} @@ -18,11 +23,11 @@ with open(ru_json_path) as f: ru_json = json.load(f) for key, value in en_json.items(): - if not key in ru_json.keys(): + if key in ru_json.keys(): + merged_json[key] = ru_json[key] + else: missing_lines[key] = value merged_json[key] = en_json[key] - else: - merged_json[key] = ru_json[key] if missing_lines: print('Найдены непереведенные строки:') @@ -31,5 +36,7 @@ if missing_lines: with open(merged_json_path, 'w') as target: obj = json.dumps(merged_json, indent=2, ensure_ascii=False, sort_keys=True) target.write(obj) + exit(1) else: print('Все строки переведены!') + exit(0)