2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-02 05:26:45 +00:00

Merge pull request #2548 from SchrodingersGat/i18n-fix

Fix for i18n javascript
This commit is contained in:
Oliver 2022-01-14 00:26:35 +11:00 committed by GitHub
commit a066b9b18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -451,8 +451,17 @@ class I18nStaticNode(StaticNode):
replaces a variable named *lng* in the path with the current language replaces a variable named *lng* in the path with the current language
""" """
def render(self, context): def render(self, context):
self.path.var = self.path.var.format(lng=context.request.LANGUAGE_CODE)
self.original = getattr(self, 'original', None)
if not self.original:
# Store the original (un-rendered) path template, as it gets overwritten below
self.original = self.path.var
self.path.var = self.original.format(lng=context.request.LANGUAGE_CODE)
ret = super().render(context) ret = super().render(context)
return ret return ret
@ -480,4 +489,5 @@ else:
# change path to called ressource # change path to called ressource
bits[1] = f"'{loc_name}/{{lng}}.{bits[1][1:-1]}'" bits[1] = f"'{loc_name}/{{lng}}.{bits[1][1:-1]}'"
token.contents = ' '.join(bits) token.contents = ' '.join(bits)
return I18nStaticNode.handle_token(parser, token) return I18nStaticNode.handle_token(parser, token)