On Fri, Jan 29, 2010 at 2:12 AM, Damien Baty <damien.b...@gmail.com> wrote:
>  Does anyone have feedback about i18n with BFG?

Personally I'd suggest to use Babel instead of zope.i18n. It's in more
widespread use in the general Python community and a more
full-featured solution. Once you want locale data like translated
language, country names or the like, zope.i18n doesn't offer anything
current or particular useful.

> 6. In each ".../LC_MESSAGES", add a translation file, say "myapp.po". It
> uses the "gettext" standard. (Looking at an <a href=existing file is usually
> the best way to get started:


>  Be sure to indicate the same domain in this file and in the template
> (cf. "i18n:domain" tag).

There's no domain header inside the file in gettext. The filename
"myapp.po" is designating the domain. Using a custom domain header is
an invention of some custom Zope2 (Plone) specific translation
handling (it's only used in i18n-style folders for

Instead of linking to a file, I'd just include an example of the
typical header here, like:

msgid ""
msgstr ""
"Project-Id-Version: myapp\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <em...@address>\n"
"Language-Team: LANGUAGE <l...@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"

The file you linked has a couple more Plone inventions in it, which
aren't valid gettext headers and not used by anyone (not even

One more catch with zope.i18n is a pretty big deviation from the
gettext standard if you use either zope.i18nmessageid or use explicit
message ids like in: <p i18n:translate="title_foo">Foo</p> I'd suggest
you don't use any of the two or your po files will have to use a
non-standard format, which gives a lot of trouble with any tools
working on those files.

> 10. In your views, instead of calling
> "repoze.bfg.chameleon_zpt.render_template_to_response()", call this method:
>    from repoze.bfg.chameleon_zpt import render_template_to_response as
> base_render
>    from myapp.i18n import getPreferredLanguage
>    def render_template_to_response(template, request, **kwargs):
>        kwargs.update(target_language=getPreferredLanguage(request))
>        return base_render(template, **kwargs)

Did I miss the code for getPreferredLanguage?

Repoze-dev mailing list

Reply via email to