[Catalyst] Proper ngettext with Catalyst

Cosimo Streppone cosimo at streppone.it
Sun Feb 1 20:31:36 GMT 2009


In data 31 gennaio 2009 alle ore 17:29:39, Nikolai Prokoschenko  
<nikolai at prokoschenko.de> ha scritto:

> Locale::Maketext::Lexicon, which C::P::I18n bases on, doesn't support
> standard plural forms.

I worked on implementing i18n/l10n for a fairly big non-catalyst
web site, and that's based on Locale::Maketext.

When I researched on how to do this, it seemed there was just one
way to do things, but it wasn't the case... :-)

> An example: if I wanted to translate the string
> "I have $x apples" I would write using gettext: ngettext("I have %d
> apple", "I have %d apples", $x). Thus xgettext would produce:

What about the zero form?
Some languages have a totally different idea of
the zero/single/plural form.

I also encountered some problems with xgettext/xgettext.pl,
that I wanted to address in the future.

In particular, they work in a slightly different way,
so I had to use the former to extract messages from the templates,
and the latter to extract them from code. Plus, xgettext.pl is much
slower, and it shouldn't be.

> msgid "I have [quant,_1,apple,apples]"
> msgstr ""
>
> a. is wrong technically, [...]
> b. is wrong semantically, [...]
> c. forces translators to deal [...]

> The only solution I've came up with so far is taking parts of
> Locale::gettext_pp and building up a module which uses standard
> gettext tools.

I just checked L::M::Lexicon and it seems a lot more work has been
done since my last patches to keep user comments (0.67).

I'm looking forward to help improving I18N/L10N in Locale::Maketext,
since I'm in the process of adding support for 21 different languages,
plus one rtl language for experimental/testing purposes.

> Can anyone recommend a sane solution for this problem?

I don't know really. I'm learning along the way, but I think
we should try to "join forces" on this.

Maybe there's a specific mailing list about l10n or L::M?

-- 
Cosimo



More information about the Catalyst mailing list