Skip to content

Commit

Permalink
Merge pull request #420 from malthe/issue-419
Browse files Browse the repository at this point in the history
Fix issue where macro would not get correctly rendered for a translation name
  • Loading branch information
malthe authored Apr 4, 2024
2 parents 95ceb0c + 8a3f589 commit c265cbd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
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>

0 comments on commit c265cbd

Please sign in to comment.