[Catalyst] Translations in Catalyst

J. Shirley jshirley at gmail.com
Thu Dec 11 04:35:46 GMT 2008

On Wed, Dec 10, 2008 at 10:44 AM, Keith Hasely <groupskhasely at mac.com> wrote:
> Hey All,
> We are evaluating different frameworks to use, and one big aspect of the project is how translations are handled, we deal with at least five languages on a regular basis.  I am hoping to get some input on different template systems, and ways you all have dealt with the multilingual issues in Catalyst.  We've been using XML XSLT translations, but people in the office find it challenging working with instead of an HTML template system.
> I've seen some modules in CPAN that help with the issue such as "Catalyst::Plugin::I18N" which seems to work with Template Toolkit, and Pedal.  There seems to be some concern over here with the overhead HTML template systems will take up compared to working with XML XSLT translations.  I've also noticed the "Catalyst::View::XSLT" class which means we wouldn't need to come up with a new system to get our content translated before we publish.
> Thanks,
> Keith

Hi Keith,

I'd just like to point out that Catalyst::Plugin::I18N (and related,
Catalyst::Plugin::Unicode) are not actually tied to your view.  They
create a method on the context ($c, by default as most people know it;
and actually on the application -- not necessarily $c, which is
currently a blessed "MyApp", so also available via a simple
MyApp->localize(...)) called "localize" (or a short-cut, "loc") that
references the .po files.

The .po files are just standard internationalization files, loaded at
run-time and editable/parsable by any standard file.  There are also
handy modules available on the CPAN that allow you to extract and
generate your .po files (gettext.pl).

This is by far the best method for internationalization because it
uses the most common standard for it, and it isn't tied towards any
view.  I haven't used Catalyst::View::XSLT (mostly because I find xslt
to be challenging ;)) so I can't say for sure, but a glance at the pod
seems that it would work something like:
       <xsl:value-of select="catalyst:loc('Foo')" />

Failing that, you can presumably register the method while creating
the XSLT instance.

Hope this helps,

More information about the Catalyst mailing list