[Catalyst] Multilingual Site

Yuval Kogman nothingmuch at woobling.org
Tue Feb 19 18:56:05 GMT 2008


On Tue, Feb 19, 2008 at 19:07:05 +0100, Michael Schreier wrote:
> I want to create a "Multilingual Site", but I don't know how to begin, 
> especially with catalyst.

Basically it comes down to using a localization engine for all text.

How you do that is up to you.

Catalyst's I18N plugin provides DWIM to choose the right language
based on the headers, and eventually delegates to Locale::Maketext.

I'd read this article thoroughly:

	http://search.cpan.org/~jhi/perl-5.8.1/lib/Locale/Maketext/TPJ13.pod

at which point things should become clear to you.

Typically people use a 'loc' function in TT.

In the last work website which was pretty heavily i18nized the
'loc' function in TT delegated to a method of an object that then
based on the arguments decided what to do. It handled everything
from objects that can be displayed, to text messages (using
Locale::Maketext::Lexicon, .po files and ::Slurp for larger bits of
text), to DateTime objects, and it worked out pretty well.

> Where is the best place to save the language texts (DB or File)? How to 
> handle templates with TT? Every link, hint and help is welcome... I need 
> a thought-provoking impulse, no final solution.

Locale::Maketext will help make the storage of the language text
irrelevant wrt the usage... If you find you need to move the data to
a database it should be trivial to do that post factum, but I'd
start with gettext files which are good enough for 90% of the cases.

One clever trick with gettex/maketextt is that you can do %foo(...)
to call method calls on the localization handle, so the formats can
localize their arguments properly without you having to localize
them before passing them in. This is both cleaner and more language
independant.

Good luck

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418




More information about the Catalyst mailing list