[Zope3-Users] PT, i18n and dynamic attributes...how to?

Sascha Ottolski sascha.ottolski at lalisio.com
Thu Feb 1 11:51:23 EST 2007


Hi,

I'm wondering if there is a proper solution to a common problem: 
translating a page template with dynamic attributes. If I put something 
like

    <p i18n:translate="">
      Hi, please <a tal:attributes="href view/click_url">click</a> here!
    </p>

in a page template, this wouldn't be translated properly, cause it ends 
in a msgid like

    msgid="Hi, please <a href=\"${DYNAMIC_CONTENT}\">click</a> here!"

Therefore I end up writing

    <p tal:content="structure view/renderLink"></p>

    class MyView:

        def renderLink(self):
            return _('Hi, please <a href="${href}">click</a> here!',
                mapping={'href': self.click_url()}

to get a msgid that reads

    msgid="Hi, please <a href=\"${href}\">click</a> here!"

Isn't there a way to express the same in the PT alone? Or should the 
first example do the trick, and it should be considered a bug that it 
doesn't?


Thanks, Sascha

-- 
Lalisio GmbH                                          www.lalisio.com

Puschkinstraße 1                             fon +49-(0)361/541 43 80
99084 Erfurt                                 fax +49-(0)361/541 43 79
                                                  kontakt at lalisio.com


More information about the Zope3-users mailing list