You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
target_language not passed to the translate method in certain cases #369
I have a template where I define i18n:target.
That adds to the local variables a variable target_language.
That variable is not passed when we are going to translate the messages in many cases.
I did a stupid test applying this patch:
[ale@flo chameleon]$ git diff
diff --git a/src/chameleon/i18n.py b/src/chameleon/i18n.py
index 449cda1..bb85734 100644
--- a/src/chameleon/i18n.py
+++ b/src/chameleon/i18n.py
@@ -82,6 +82,7 @@ else: # pragma: no cover
def simple_translate(msgid, domain=None, mapping=None, context=None,
target_language=None, default=None):
+ print(f"simple_translate called with msgid={msgid} target_language={target_language}")
if default is None:
default = getattr(msgid, "default", msgid)
[ale@flo chameleon]$ ./py3/bin/python test.py
simple_translate called with msgid=foo target_language=None
simple_translate called with msgid=foo target_language=None
simple_translate called with msgid=foo target_language=test
<html
>
target_language: test
Foo
Foo
Foo
</html>
As you can see:
the can render the proper value for target_language
${foo} is processed passing target_language=None
<tal:foo replace="structure foo" /> is processed passing target_language=None
Only if I add i18n:translate="" (which I would not expect to need), the target_language is properly passed.
Activity
malthe commentedon Nov 15, 2023
This should be fixed now.