On Wednesday, August 20, 2014 7:28:28 PM UTC+2, Wichert Akkerman wrote:
>
>
> > On 20 Aug 2014, at 19:21, Oscar Curero <flex...@gmail.com <javascript:>> 
> wrote: 
> > 
> > Hi, 
> > 
> > I'm building my first application using pyramid and chameleon and I'm 
> having problems with the localized URL schema. It's something like this: 
> > 
> > /en/products 
> > /es/productos 
> > /ca/productes 
> > 
> > The problem starts when I need to make the HTML templates. For example, 
> I want to make the following template: 
> > 
> > <p><a href="/${request.locale_name}/${products}"><img src="products.jpg" 
> alt="" /></a></p> 
>
> The problem here is that ${products} assumes that you have a python 
> variable named “products” at hand and want to insert its value in the 
> template. But since you have no such variable you get a NameError 
> exception. If you goal is to make the word “products” translatable you can 
> do this: ${_(“products”)} . 
>
> Wichert. 
>

Thanks Wichert. If I try what you say with nothing else, it doesn't work 
yet:

NameError: _

 - Expression: "${request.locale_name}/${_('products')}"
 - Filename:   ... ate/templates/products.pt
 - Location:   (line 10: col 30)
 - Source:     ... <p><a href="/${request.locale_name}/${_('products')}"><img 
...

However, if I add at the top of the template the following statement, it works 
as expected:


<?python from pyramid.i18n import TranslationString as _ ?>

Is this the way it should work?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to