mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-13 10:35:40 +00:00
JS translation fix (#6288)
* Implement {% jstrans %} template - Forces string escaping in translated text - Required for js written in templates * Fix part_base.html * Update .html files - Change any templated javascript code to use {% jstrans %} * Update .js files - Explicitly use {% jstrans %} * Update CI checks
This commit is contained in:
@ -50,6 +50,7 @@ def check_prohibited_tags(data):
|
||||
'for',
|
||||
'endfor',
|
||||
'trans',
|
||||
'jstrans',
|
||||
'load',
|
||||
'include',
|
||||
'url',
|
||||
@ -84,17 +85,18 @@ for filename in pathlib.Path(js_dynamic_dir).rglob('*.js'):
|
||||
with open(filename, 'r') as js_file:
|
||||
data = js_file.readlines()
|
||||
|
||||
pattern = r'{% trans '
|
||||
invalid_tags = ['trans', 'jstrans']
|
||||
|
||||
err_count = 0
|
||||
|
||||
for idx, line in enumerate(data):
|
||||
results = re.findall(pattern, line)
|
||||
for tag in invalid_tags:
|
||||
tag = '{% ' + tag
|
||||
if tag in line:
|
||||
err_count += 1
|
||||
|
||||
if len(results) > 0:
|
||||
errors += 1
|
||||
print(f" > Error on line {idx+1}: Prohibited tag '{tag}' found")
|
||||
|
||||
print(f' > prohibited {{% trans %}} tag found at line {idx + 1}')
|
||||
|
||||
if errors > 0:
|
||||
print(f'Found {errors} incorrect template tags')
|
||||
|
Reference in New Issue
Block a user