mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 21:16:46 +00:00
enable live-serving of i18n_static tag in debug (#1560)
* enable live-serving of i18n_static tag in debug * style repair
This commit is contained in:
parent
5ed17022f2
commit
bdd61fdb2c
@ -200,18 +200,28 @@ class I18nStaticNode(StaticNode):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@register.tag('i18n_static')
|
# use the dynamic url - tag if in Debugging-Mode
|
||||||
def do_i18n_static(parser, token):
|
if settings.DEBUG:
|
||||||
"""
|
|
||||||
Overrides normal static, adds language - lookup for prerenderd files #1485
|
|
||||||
|
|
||||||
usage (like static):
|
@register.simple_tag()
|
||||||
{% i18n_static path [as varname] %}
|
def i18n_static(url_name):
|
||||||
"""
|
""" simple tag to enable {% url %} functionality instead of {% static %} """
|
||||||
bits = token.split_contents()
|
return reverse(url_name)
|
||||||
loc_name = settings.STATICFILES_I18_PREFIX
|
|
||||||
|
|
||||||
# change path to called ressource
|
else:
|
||||||
bits[1] = f"'{loc_name}/{{lng}}.{bits[1][1:-1]}'"
|
|
||||||
token.contents = ' '.join(bits)
|
@register.tag('i18n_static')
|
||||||
return I18nStaticNode.handle_token(parser, token)
|
def do_i18n_static(parser, token):
|
||||||
|
"""
|
||||||
|
Overrides normal static, adds language - lookup for prerenderd files #1485
|
||||||
|
|
||||||
|
usage (like static):
|
||||||
|
{% i18n_static path [as varname] %}
|
||||||
|
"""
|
||||||
|
bits = token.split_contents()
|
||||||
|
loc_name = settings.STATICFILES_I18_PREFIX
|
||||||
|
|
||||||
|
# change path to called ressource
|
||||||
|
bits[1] = f"'{loc_name}/{{lng}}.{bits[1][1:-1]}'"
|
||||||
|
token.contents = ' '.join(bits)
|
||||||
|
return I18nStaticNode.handle_token(parser, token)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user