[Zope3-Users] Translations with variables embedded in HTMLattributes

Doyon, Jean-Francois jdoyon at NRCan.gc.ca
Tue Aug 28 15:46:56 EDT 2007


Seems like you're trying to manipulate a string (a URL?) to do
translation within it, in which case you shouldn't do this within your
TAL, but instead have a separate piece of logic to do it (Python Script
for example).

-----Original Message-----
From: zope3-users-bounces at zope.org [mailto:zope3-users-bounces at zope.org]
On Behalf Of Asheesh Laroia
Sent: August 28, 2007 14:54
To: zope3-users at zope.org
Subject: [Zope3-Users] Translations with variables embedded in
HTMLattributes

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="&lt;span i18n:name='lang'
tal:content='view/target_lang' /&gt;">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
_______________________________________________
Zope3-users mailing list
Zope3-users at zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


More information about the Zope3-users mailing list