[Catalyst] Multilingual Site

Yuval Kogman nothingmuch at woobling.org
Thu Feb 21 17:11:14 GMT 2008


On Tue, Feb 19, 2008 at 23:28:53 +0100, Michael Schreier wrote:
> That sounds great and I'll check this for my template work, but now I 
> have an additional question.
> 
> What about user generated content? For example: I have a site with three 
> languages "en,de,fr" and the user can make input in one or all of these 
> languages.

I would make the language a foreign key, but aside from that no real
input.

However, user localized content is probably going to be a *ROYAL*
pain... In my experience the biggest difficulty was QA for the
actual text itself.

> And how is the best way, to fetch multilingual content with DBIx::Class?

Presuming your objects have foreign keys pointing to strings, I
would delegate this to the loc function, kind of like:

	$obj->find_related( what => { language_id => $lang } )->content;

or somesuch.

You could create a helper method as a custom DBIC component, but I'd
keep it so that it always must explicitly get the language as a
parameter.

At any rate embedding the notion of the current language into the
DBIC row object sounds like high maintenance dependency injection.

By constraining the actual multilingual decisions to only the view
layer, and leaving everything open ended in the model will make
things work smoother when the application is taking a meta view on
it's localization. I can't see a reason for which language or a
default language to ever be a model concern, but I can see quite a
few reasons why not =)

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




More information about the Catalyst mailing list