From 1f7cfc357be8d0615741ac91769748000fcd9ad2 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 7 Aug 2020 08:44:46 +1000 Subject: [PATCH] add a tool to find missing i18n key in two files --- tools/compareLocalizedStrings.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tools/compareLocalizedStrings.py diff --git a/tools/compareLocalizedStrings.py b/tools/compareLocalizedStrings.py new file mode 100755 index 000000000..3b72b6711 --- /dev/null +++ b/tools/compareLocalizedStrings.py @@ -0,0 +1,30 @@ +#!/bin/python3 + + +# usage : ./tools/compareLocalizedStrings.py en de + +import re +import os +from glob import glob +import json +import sys + +if len(sys.argv) != 3: + print(f'usage: {sys.argv[0]} ') + sys.exit(1) + +src = sys.argv[1] +dest = sys.argv[2] +print(f'src {src}, dest {dest}') +jsonInEn = json.loads(open(f'_locales/{src}/messages.json', 'r').read()) +jsonInDe = json.loads(open(f'_locales/{dest}/messages.json', 'r').read()) +keysInEn = jsonInEn.keys() +keysInDe = jsonInDe.keys() + +print(keysInEn) + +for key in keysInEn: + if key not in keysInDe: + print(f'not found in de:{key}') + +print(f'total keys in en {len(keysInEn)}') \ No newline at end of file