[Product-Developers] Re: Question about i18n message in python files

Radim Novotny novotny.radim at gmail.com
Sat Apr 26 15:59:12 UTC 2008


from zope.i18n import translate
translated_string = translate(_(u"N/A"), context=self.context)



Jean-Pascal Houde napsal:
> Thanks, that's what I was suspecting.
> Is there a way to do the translation in python? (I guess there must be
> a way since the template engine does it, but I didn't find anything by
> looking at the class or the attributes of the message)
> 
> On Apr 25, 6:17 pm, "Steve McMahon" <st... at dcn.org> wrote:
>> I'm pretty sure that _(u'N/A') is creating a MessageFactory message
>> object. No translation is done at that point, as the target language
>> isn't known 'til page rendering.
>>
>> These message objects are polymorphous, and if you concatenate one to a string:
>>
>> _(u'N/A') + 'oops'
>>
>> or even to another message, the result is a string -- not a message.
>>
>> You need to do the concatenation in the page template.
>>

--
Radim Novotny





More information about the Product-Developers mailing list