Browse Source

add initial script to check for missing en strings

pull/111/head
Jonathan Wright 2 years ago
parent
commit
1053f72c3f
  1. 26
      find_missing_i18n_strings.py

26
find_missing_i18n_strings.py

@ -0,0 +1,26 @@
import re
import os
import json
en = json.load(open('i18n/en.json'))
error = False
dict = {}
rootdir=('.')
for folder, dirs, files in os.walk(rootdir):
for file in files:
if file.endswith('.html'):
fullpath = os.path.join(folder, file)
with open(fullpath, 'r') as f:
for line in f:
m = re.match('.*{{\s+?i18n\s+?(?:"|`)(.*)(?:"|`)\s+?}}', line)
if m:
string = m.group(1)
if string not in en:
error = True
print(f'TRANSLATION ERROR: {string}')
dict[string] = string
if error:
print(json.dumps(dict, indent=3))
exit(1)
Loading…
Cancel
Save