Usted está aquí: Inicio CS-Workshop CS-Workshop Blog Topics i18n

i18n

My Plone doesn't show translated msgids located in a locales directory !!

by Mikel Larreategi — última modificación 16/04/2008 00:00
Etiquetas:

In a project I'm currently working on, I have written a product following the new way of writing Plone products: creating an egg and putting its translations in a locales directory.

After translating the msgids, creating the po files and reading once and again the Maurits' post although I'm on Plone 2.5, I was seeing always the same translated strings, always in the language my browser was configured in, no matter I changed the language using Plone's language selector.

After googling a bit, I found this Five and i18n tutorial in which Phillip says:

The goal of the sprint was to allow both fallback translation services (PTS, Localizer) and Zope 3 translation domains come to the same conclusion regarding which language should be chosen. The use case is that you have a site running Localizer or PTS and a bunch of "old" products using either one of those for translation. Now you have an additional, "new" Five-based product using Zope 3 translation domains. Most of the time, a page contains user messages from more than one domain, so you would all domains be translated to the same language.

So, I just have to add an overrides.zcml file to my product (and load it in my buildout), with the following content:

<adapter
for="zope.publisher.interfaces.http.IHTTPRequest"
provides="zope.i18n.interfaces.IUserPreferredLanguages"
factory="Products.Five.i18n.PTSLanguages"
/>

Now, Five and Zope3 components of my Plone site, negotiate the language just like PTS does, so I have correctly translated msgids in my site.