Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where macro would not get correctly rendered for a translation name #420

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Changes

In next release ...

-
- Fix a bug where a macro could not be used correctly to render a
translation name.
(`#419 <https://github.com/malthe/chameleon/issues/419>`_)

4.5.2 (2024-01-29)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/chameleon/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ def visit_Name(self, node):

# generate code
code = self.visit(node.node)
body.append(TranslationContext(code, append))
body.append(TranslationContext(code, append, stream))

# output msgid
text = Text('${%s}' % node.name)
Expand Down
5 changes: 5 additions & 0 deletions src/chameleon/tests/inputs/128-translation-macro-name.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<a metal:define-macro="fancy-link" href="#">Fancy link</a>

<tal:something i18n:translate="text_with_link">
Now follows a fancy link: <metal:fancy-link i18n:name="obj_link" use-macro="macros['fancy-link']" />
</tal:something>
3 changes: 3 additions & 0 deletions src/chameleon/tests/outputs/128-en.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="#">Fancy link</a>

Now follows a fancy link: <a href="#">Fancy link</a> ('text_with_link' translation into 'en')
3 changes: 3 additions & 0 deletions src/chameleon/tests/outputs/128.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="#">Fancy link</a>

Now follows a fancy link: <a href="#">Fancy link</a>
Loading