From d6672372a51541fd77913f9ad3d5962456bbd898 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 5 Aug 2021 00:44:02 +0200 Subject: [PATCH] script to save the locale stats --- .gitignore | 5 ++++- InvenTree/script/translation_stats.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c53a837e24..5610fc4304 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,7 @@ secret_key.txt htmlcov/ # Development files -dev/ \ No newline at end of file +dev/ + +# Locale stats file +locale_stats.json diff --git a/InvenTree/script/translation_stats.py b/InvenTree/script/translation_stats.py index f47a21f168..c6126f2944 100644 --- a/InvenTree/script/translation_stats.py +++ b/InvenTree/script/translation_stats.py @@ -3,6 +3,7 @@ This script calculates translation coverage for various languages """ import os +import json def calculate_coverage(filename): @@ -36,8 +37,10 @@ if __name__ == '__main__': MY_DIR = os.path.dirname(os.path.realpath(__file__)) LC_DIR = os.path.abspath(os.path.join(MY_DIR, '..', 'locale')) + STAT_FILE = os.path.abspath(os.path.join(MY_DIR, '..', 'InvenTree/locale_stats.json')) locales = {} + locales_perc = {} print("InvenTree translation coverage:") @@ -64,5 +67,10 @@ if __name__ == '__main__': percentage = 0 print(f"| {locale.ljust(4, ' ')} : {str(percentage).rjust(4, ' ')}% |") + locales_perc[locale] = percentage print("-" * 16) + + # write locale stats + with open(STAT_FILE, 'w') as target: + json.dump(locales_perc, target)