Trying to understand M::P::I18N

42 views
Skip to first unread message

Ekki Plicht

unread,
Nov 16, 2012, 7:57:05 AM11/16/12
to mojol...@googlegroups.com
Hi,
I am using the M::P::I18N plugin 0.81, but don't understand the rationale behind some behaviour of that module.

My templates live in templates/de, templates/en, templates/fr and so on. They are not totally localized, i.e. they differ between languages. It would be way too complicated to make one template for all languages. Even more, some pages exist in one language, but not in another.

A simple scanner generates routes automatically from the templates directories, there are about 1200 templates. This is due to the fact that we want to move gradually from an old static site to a more dynamic site, replacing the currently only partially localized templates with more generic ones. Still these template files are not just static, they do contain dynamic elements.

So, first question:
What's the rationale behind 'clean path', i.e. removing the language code ('de' in example.com/de/foo.html) from the url->path->parts before the router gets hit? This leads the router to look for example.com/foo.html instead of example.com/de/foo.html. Currently I have forked the I18N module and disabled this feature with a new parameter (no_clean_path => 1) .

Second question:
M::P::I18N checks the languages from the request header. Depending on the clients browser settings this can yield nearly anything, for example 'en_us'. My browser supplies 'de, en_us, en, fr' in descending order of priority. I understand that Locale::Maketext tries to fallback to the next lower priority when a higher is not available. This leads I18N to try to load the module MyApp::I18N::en_us for each request. It fails of course, because that does not exist. Is there an easy way to map 'en_us' an such like to 'en'?

Thanks,
Ekki

Reply all
Reply to author
Forward
0 new messages