2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Translation stat fix (#5250)

* Add helper function for translation coverage

- Handle case where locale name does not match exactly

* remove debug statement

* Fixes
This commit is contained in:
Oliver
2023-07-15 08:38:39 +10:00
committed by GitHub
parent 4a46e0321f
commit 034cc4b983
4 changed files with 63 additions and 12 deletions

View File

@ -10,9 +10,21 @@ from django.templatetags.i18n import TranslateNode
import bleach
import InvenTree.translation
register = template.Library()
@register.simple_tag()
def translation_stats(lang_code):
"""Return the translation percentage for the given language code"""
if lang_code is None:
return None
return InvenTree.translation.get_translation_percent(lang_code)
class CustomTranslateNode(TranslateNode):
"""Custom translation node class, which sanitizes the translated strings for javascript use"""