Current

This document is valid for the current version of Plone.

Manually translating message ids

by Plone Documentation Team last modified Dec 12, 2009 10:54 PM
Contributors: Mikko Ohtamma, Martin Aspeli, Kamon Ayeva, Israel Saeta Pérez
If you are outputting text outside page templates you need to make sure it runs through translate() function yourself

If you need to manipulate translated text outside page templates, you need to perform the final translation manually.

Translation always needs context (i.e. under which site translation happens), as the active language and other preferences are read from the HTTP request object and site settings.

Translation can be performed using context.translate() method which all content objects inherit:

# Create a message id which will be translated
msgid = _(u"My text")

# Use translate() function to get the final text string
translated = self.context.translate(msgid)

# translated value is now u"Käännetty teksti" (in Finnish)