script to save the locale stats

This commit is contained in:
Matthias 2021-08-05 00:44:02 +02:00
parent 3ecb1e6577
commit d6672372a5
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 12 additions and 1 deletions

3
.gitignore vendored
View File

@ -68,3 +68,6 @@ htmlcov/
# Development files
dev/
# Locale stats file
locale_stats.json

View File

@ -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)