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

i18n:msg for nested and repeated tags incorrectly translates message #69

Open
jun66j5 opened this issue Apr 3, 2023 · 1 comment
Open

Comments

@jun66j5
Copy link
Member

jun66j5 commented Apr 3, 2023

>>> import genshi
>>> genshi.__version__
'0.7.7'
>>> from genshi.template import MarkupTemplate
>>> from genshi.filters.i18n import Translator, extract
>>> html = """<html xmlns:py="http://genshi.edgewall.org/"
...     xmlns:i18n="http://genshi.edgewall.org/i18n"
...     py:strip="">
...   <i18n:msg>
...     <ul><li>First</li><li>Second</li></ul>
...   </i18n:msg>
... </html>"""
>>>
>>> tmpl = MarkupTemplate(html)
>>> translator = Translator()
>>> tmpl.add_directives(Translator.NAMESPACE, translator)
>>> result = list(translator.extract(tmpl.stream))
>>> msg = result[0][2]
>>> msg
'[1:[2:First][3:Second]]'
>>>
>>> tmpl = MarkupTemplate(html)
>>> translator = Translator(lambda s: msg)
>>> translator.setup(tmpl)
>>> tmpl.generate().render()
'\n  <ul><li>First</li></ul><li>Second</li>\n'
#                      ^^^^^           ^^^^
#    <ul><li>First</li><li>Second</li></ul>
@hodgestar
Copy link
Contributor

Thanks for reporting this. So the closing end tag is being placed before the last sub-element rather than after it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants