2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-05 19:41:41 +00:00

JS translation fix (#6288) (#6289)

* 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:
Oliver
2024-01-19 13:37:48 +11:00
committed by GitHub
parent 3a37947dbb
commit 774d0f50fd
49 changed files with 1690 additions and 1664 deletions

View File

@@ -51,6 +51,7 @@ def check_prohibited_tags(data):
'for',
'endfor',
'trans',
'jstrans',
'load',
'include',
'url',
@@ -89,18 +90,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):
for tag in invalid_tags:
tag = '{% ' + tag
if tag in line:
err_count += 1
results = re.findall(pattern, line)
print(f" > Error on line {idx+1}: Prohibited tag '{tag}' found")
if len(results) > 0:
errors += 1
print(f" > prohibited {{% trans %}} tag found at line {idx + 1}")
if errors > 0:
print(f"Found {errors} incorrect template tags")