[Catalyst] Choosing the language
Octavian Râsnita
orasnita at gmail.com
Tue Oct 13 13:16:16 GMT 2009
From: "Larry Leszczynski" <larryl at emailplus.org>
> Hi (again) Octavian -
>
>> Is there a recommendation for storing the language ID in the URL in order
>> to
>> 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
>> every
>> action separately.
>
> Here is one way to have it in the URL without all controllers needing to
> be aware:
>
> http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing
>
>
> HTH,
> Larry
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
app.
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
directly?
Thank you.
Octavian
More information about the Catalyst
mailing list