On Fri, Oct 23, 2009 at 12:41:48PM -0700, Mariano Mara wrote:
> Hi,
>  I have this mako template where I want to print a message but part of
> it depends on a certain variable that I will get from the controller.
>  E.g.:
>  ${_(u'No tickets were found in the last n days')}
>  where "n" comes from the variable c.lastNdays in the controller.

You probably want ngettext instead of _ then.  How to hook it up with
everything is left as an excercise for the reader.

>  How can I place it correctly in the template?
>  I'm using
>   ${_(u'No tickets were found in the last ')}${c.lastNdays} ${_
> (u'days')}
>  but I'm sure there should be a better way to have a proper
> translatable string, like:
>  ${_(u'No tickets were found in the last %(num)d days') %
> {'num':c.lastNdays}}
>  although this last one raises an error in the template.

I'm guessing it's because the expression gets terminated at the first }?

I'd go with dict(num=c.lastNdays) instead of {'num':c.lastNdays} (also,
missing space after ':' hurts my eyes).

Marius Gedminas
-- 
All those who believe in psychokinesis raise my hand.

Attachment: signature.asc
Description: Digital signature

Reply via email to