Skip to content

Commit

Permalink
fix: conf.i18n.add_missing_translations the right way (#1409)
Browse files Browse the repository at this point in the history
- evaluate the switch first in any conditions
- missing evaluation of `add_missing_translations` in {% translate ...
%} constructs
  • Loading branch information
phorward authored Feb 11, 2025
1 parent 1d5f7a8 commit 16603e1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/viur/core/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def __init__(
self.public = public
self.filename, self.lineno = None, None

if self.key not in systemTranslations and conf.i18n.add_missing_translations:
if conf.i18n.add_missing_translations and self.key not in systemTranslations:
# This translation seems to be new and should be added
for frame, line in traceback.walk_stack(sys._getframe(0).f_back):
if self.filename is None:
Expand All @@ -227,7 +227,7 @@ def __str__(self) -> str:
if self.translationCache is None:
global systemTranslations

if self.key not in systemTranslations and conf.i18n.add_missing_translations:
if conf.i18n.add_missing_translations and self.key not in systemTranslations:
# This translation seems to be new and should be added

add_missing_translation(
Expand Down Expand Up @@ -344,7 +344,7 @@ def parse(self, parser):
tr_key = args[0].lower()
public = kwargs.pop("_public_", False) or False

if tr_key not in systemTranslations:
if conf.i18n.add_missing_translations and tr_key not in systemTranslations:
add_missing_translation(
key=tr_key,
hint=args[1],
Expand Down

0 comments on commit 16603e1

Please sign in to comment.