[Zope3-Users] Translations with variables embedded in HTML
attributes
Asheesh Laroia
asheesh at creativecommons.org
Tue Aug 28 14:53:46 EDT 2007
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' />">home</a>
That's pretty awful, and Zope retaliates by thinking I want to ask the
i18n system for this:
<a href="<span i18n:name='lang' tal:content='view/target_lang' />">home</a>
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
More information about the Zope3-users
mailing list