|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Choosing the languageHi,
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. I was also thinking to chain dispatching, but I don't know how I could set a chain for the entire application that just gets the language and stores it in the stash. Please tell me how you use to do this. Thank you. Octavian _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the languageHi (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 _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the languageOn 12 Oct 2009, at 22:30, Octavian Râşniţă wrote: > Is there a recommendation for storing the language ID in the URL in > order to be as easy to get it from there? Catalyst::TraitFor::Request::PerLanguageDomains Cheers t0m _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the language2009/10/12 Octavian Râşniţă <orasnita@...> Hi, My other post about passing around query parameters is related. Happens that one of the parameters is a lang setting. I've always preferred using a path prefix instead of a query parameter. For one things it make relative urls work. Another is that, IIRC, there were proxies that would not cache content with query parameters. I'm not sure if that's a real concern any more -- or if there's any other reasons to avod the query parameter approach. Another parameter that might be passed, in my case, is a session id. I'm not a fan of that, but apparently there's some cases where it's needed (site in an iframe??). At one time I also put that into a path prefix. 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. The wiki article Larry posted is very close to what I do. -- Bill Moseley moseley@... _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the languageFrom: "Larry Leszczynski" <larryl@...>
> 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 _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the languageOn Tue, Oct 13, 2009 at 4:16 PM, Octavian Râsnita <orasnita@...> wrote:
> From: "Larry Leszczynski" <larryl@...> >> >> 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? > > > Octavian, 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 =) Regards, Pavel Karoukin _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the language> > http://dev.catalyst.perl.org/wiki/wikicookbook/urlpathprefixing > > 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? Sorry, copy/paste error - $self should not be in there. I've tweaked the wiki page. _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
|
|
Re: Choosing the languageOn Tue, Oct 13, 2009 at 9:35 AM, Pavel O. Korovkin <hippich@...> wrote:
Might I also suggest splitting out Location from Language and treating them as a key pair. For instance, http://example.com/us/en/foo/bar/. Just because two countries may speak Spanish does not mean their content (and static assets like images!) would be the same -- they may very well differ because of legal, cultural differences or local services/products. Even if a site starts out with 100% translated/mirrored content, it is advisable to build flexibility into the url structure. Also, depending on your roll out and domain plan, take into consideration that country specific domains should be able to publish the country and language default content. http://example.co.ae/en/ serves ~ http://example.com/ae/en/. -Wade -- Thanks! Wade Stuart Phone: 917-363-6164 IM: SpaceMuscles _______________________________________________ List: Catalyst@... Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@.../ Dev site: http://dev.catalyst.perl.org/ |
| Free embeddable forum powered by Nabble | Forum Help |