[Catalyst] Choosing the language
Pavel O. Korovkin
hippich at gmail.com
Tue Oct 13 13:35:13 GMT 2009
On Tue, Oct 13, 2009 at 4:16 PM, Octavian Râsnita <orasnita at gmail.com> wrote:
> From: "Larry Leszczynski" <larryl at emailplus.org>
>> Hi (again) Octavian -
>>> Is there a recommendation for storing the language ID in the URL in order
>>> be as easy to get it from there?
>>> I want to have unique links for each URL, so I can't just put it in the
>>> cookies. Using ?lang=EN seems to be the easiest way, although it doesn't
>>> look nice.
>>> Putting it as the first element in the path info looks nice, but I don't
>>> know how to get it from there in a single controller/action and not in
>>> action separately.
>> Here is one way to have it in the URL without all controllers needing to
>> be aware:
> Thank you Larry. It seems to be what I need.
> I've seen some uses of $self which were not defined in that example.
> Shouldn't be __PACKAGE__ instead?
> Unfortunately I don't know how to make it work in some cases:
> 1. If I use the test Catalyst server the static URLS that begin with /static
> don't work because I can't configure that server to not handle /static URLS.
> (But this is not so important).
> 2. Most important, if I need to use
> [% c.uri_for('/static', 'css', 'layout.css') %]
> for making it work even if I need to change the base location the app
> handles, then the static files are not served by Apache directly but by the
> If the app listens to the / location, the request is in this case:
> GET /en/static/css/layout.css HTTP/1.1
> I think I could make a hack somehow and configure Apache to do a request to
> /static whenever the user tries to access /en/static or /fr/static... but I
> guess this could be done with mod_rewrite which I don't know how to use yet.
> Is there a more simple method to make the web server serve the static files
I think it's a "feature". Think about it if you will need different
images for different languages, for example. Or RTL stylesheets for
rtl languages. And you can use symlinks for now while you do not need
these "features", or mod_rewrite to rewrite path to /static/ if there
is no /en/static/ yet =)
More information about the Catalyst