Hi Morten,

On Tue, May 31, 2011 at 13:19,  <li...@nidelven-it.no> wrote:
> Hi,
> I have a oldschool style Zope 2 product, which has an i18n
> directory containing translations.
> Using i18n:domain="SimpleChat" in this product works fine in
> the page templates,

Well, ZPTs generate message objects automatically from translated
content, but they also explicitly translate all the message objects
they get during interpolation between the literal parts of the
template and the dynamically generated ones.

> but when I start translating text in
> a Python module using _("Translate me") I just get English
> text (instead of Norwegian, which is what I want).

When you say "I just get English text", what does exactly "get" mean
in terms of code?

Mind you, if you simple call unicode(message) you'll most likely only
get the English version back. Same thing if you do:

  u"some other string: %s" % message

To get an actual translation, you need to call
zope.i18n.translate(message), eventually passing the
"target_languate=..." parameter.

Take a look at the zope.i18n module for details, specifically the
translate() and negotiate() functions.

> The top of the module contains this:
> from zope.i18nmessageid import MessageFactory
> _ = MessageFactory('SimpleChat')

Ok so far, it's what you do with the message objects generated by _()
that is the interesting part.


Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to