Plone, Zope and the PlacelessTranslationService
Last two days I've been trying to figure out why PloneGazette didn't work properly in a Plone site I've been working on lately. Plone version was 3.0.5, on top of Zope 2.10.5, everything running (almost) fine, but that PloneGazette product didn't want to show up in my site default language (spanish).
At first, I noticed some ugly error messages in Zope's event.log:
2008-02-12T14:10:25 ERROR Zope.SiteErrorLog http://prunus:8080/Control_Panel/TranslationService/PloneGazette.i18n-plonegazette_es.po/index_html Traceback (innermost last): Module ZPublisher.Publish, line 122, in publish Module ZServer.HTTPResponse, line 262, in setBody Module ZPublisher.HTTPResponse, line 324, in setBody Module ZPublisher.HTTPResponse, line 476, in _encode_unicode UnicodeEncodeError: 'latin-1' codec can't encode character u'\ufffd' in position 4192: ordinal not in range(256)
Weird, seems like there was some problem with the translation file for spanish. After opened up the ZMI in a web browser, I took a look over the PlacelessTranslationService just to find out that the special spanish characters (accent vocals, ñ, etc) were screwed up.
After a while, I noticed that the translation file set up its charset as iso-8859-1:
"Content-Type: text/plain; charset=iso-8859-1\n"
While the file itself was encoded as UTF-8:
[prunus] /usr/local/www/zope2105/Products/PloneGazette/i18n> file plonegazette_es.po plonegazette_es.po: UTF-8 Unicode PO (gettext message catalogue) text, with very long lines [prunus] /usr/local/www/zope2105/Products/PloneGazette/i18n>
Well, easy solution to an ugly problem, just setting up the right encoding solved part of the problem:
"Content-Type: text/plain; charset=utf-8\n"
After changed the .po file, I just reload the catalog for it in the PlacelessTranslationService and the event.log error went away.
Then I noticed that the site was as its default language spanish(spain), that is, es_es, while the .po file for the spanish translation was primary for es and it was the fallback for those:
"X-Is-Fallback-For: es-ar es-bo es-cl es-co es-cr es-do es-ec es-sv es-gt es-hn es-mx es-ni es-pa es-py es-pe es-pr es-us es-uy es-ve\n"
Exactly! no es_es in there!
So, two easy solutions:
- Change the default language for the site to es
- Add es_es to the list X-Is-Fallback-For
And then the problem was solved (well, sort of, cause the .po file wasn't entirely translated anyway).