We have some translation keys with variables embedded in HTML attributes. I can't find a syntax that would let me use those keys as well as replace the variables.

Here's an example problem translation message:

        a msgid: <a href="/?lang=${lang}">home</a>

I've been experimenting with Zope 3's i18n:translate="" attribute, and it works great for translating raw HTML. So this key works:

        a msgid: <a href="/somewhere/">la-la land</a>

The way to insert variables into an i18n:translate="" string is using some container object that gets tal:replace'd with some variable, and that specifies with i18n:name what variable name it replaces. And indeed, that works. But what about the case where a variable is embedded in the query string, which is inside an attribute, as I mentioned above? The closest I've come to expressing that is this:

        <a href="<span i18n:name='lang' tal:content='view/target_lang' 

That's pretty awful, and Zope retaliates by thinking I want to ask the i18n system for this:

         <a href="&lt;span i18n:name='lang' tal:content='view/target_lang' 

So, how do I get what I actually wanted? (-:

This would be easier if you could specify variable expansions in the same tag as you do i18n:translate="", like the "tal:interpolate" suggestion at http://wiki.zope.org/zope3/ZPTInternationalizationSupport.

Let me apologize for this question. It's an ugly position we're in, but it is a real one, so I still think it's worth asking. Thanks!

-- Asheesh.

I love children.  Especially when they cry -- for then someone takes them away.
                -- Nancy Mitford
Zope3-users mailing list

Reply via email to