Set interface language via URL path
Hi, I'm being asked to write a webapp for a site that will have three versions for, one for each language. The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/. I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites. Does anybody did this before and can share a strategy? My current best solution for this would be to had a hook as soon as possible and remove the first level path if it matches one of the languages we support and set a var for it. Any other suggestions? Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Fri, Jul 05, 2013 at 05:19:37PM +0100, Pedro Melo wrote:
Hi,
I'm being asked to write a webapp for a site that will have three versions for, one for each language.
The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Does anybody did this before and can share a strategy? My current best solution for this would be to had a hook as soon as possible and remove the first level path if it matches one of the languages we support and set a var for it.
Any other suggestions?
In the same vein: use Dancer2; get '/*/**' => sub { var lang => (splat)[0]; pass; }; prefix '/*'; my %greeting = ( en => 'howdie', fr => 'bonjour', de => 'hallo', ); get '/welcome' => sub { return $greeting{ var 'lang' }; }; Another idea (and I'm just thinking out loud, so take all here with a grain of salt) could be to have a nginx or apache reverse proxy taking in the urls /de/*, /fr/*, /en/*, rewrite them as the prefix-less '*', and pass the language as an environment variable. In the same vein, you could have en.site.tld, fr.site.tld, etc. HTHAWB, (Hope That Helps A Wee Bit), `/anick --
Hi, On Fri, Jul 5, 2013 at 5:39 PM, Yanick Champoux <yanick@babyl.dyndns.org>wrote:
On Fri, Jul 05, 2013 at 05:19:37PM +0100, Pedro Melo wrote:
Hi,
I'm being asked to write a webapp for a site that will have three versions for, one for each language.
The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Does anybody did this before and can share a strategy? My current best solution for this would be to had a hook as soon as possible and remove the first level path if it matches one of the languages we support and set a var for it.
Any other suggestions?
In the same vein:
use Dancer2;
get '/*/**' => sub { var lang => (splat)[0]; pass; };
prefix '/*';
my %greeting = ( en => 'howdie', fr => 'bonjour', de => 'hallo', );
get '/welcome' => sub { return $greeting{ var 'lang' }; };
Yeah, this is similar to what I was playing with...
Another idea (and I'm just thinking out loud, so take all here with a grain of salt) could be to have a nginx or apache reverse proxy taking in the urls /de/*, /fr/*, /en/*, rewrite them as the prefix-less '*', and pass the language as an environment variable.
Also though of that, and I might be going this route. The big disadvantage is that url_for doesn't work properly anymore. In the same vein, you could have en.site.tld, fr.site.tld, etc.
This the client doesn't want. I tried. Thanks, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Fri, 5 Jul 2013, Pedro Melo wrote:
I'm being asked to write a webapp for a site that will have three versions for, one for each language.
The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Does anybody did this before and can share a strategy? My current best solution for this would be to had a hook as soon as possible and remove the first level path if it matches one of the languages we support and set a var for it.
Any other suggestions?
For static pages I use http://site.tld/name/of/document/ and than 'index' . $lang . 'html' For dynamic pages I use request->request_language() For loged-in users I use the language in there profile. There is no need for $lang in the route IMHO. How big will get ':lang' => sub { ... } be? -- Henk van Oers
Hi, On Fri, Jul 5, 2013 at 5:54 PM, Henk van Oers <hvo.pm@xs4all.nl> wrote:
On Fri, 5 Jul 2013, Pedro Melo wrote:
I'm being asked to write a webapp for a site that will have three
versions for, one for each language.
The current idea is to use http://site.tld/en/, http://**site.tld/de/<http://site.tld/de/>and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Does anybody did this before and can share a strategy? My current best solution for this would be to had a hook as soon as possible and remove the first level path if it matches one of the languages we support and set a var for it.
Any other suggestions?
For static pages I use http://site.tld/name/of/**document/<http://site.tld/name/of/document/> and than 'index' . $lang . 'html'
For dynamic pages I use request->request_language()
For loged-in users I use the language in there profile.
There is no need for $lang in the route IMHO.
/LANG/ prefix should not be needed if you can trust language negotiation, sure. But I'm tired of fighting proxys that cache pages ignoring those headers to go this route. How big will get ':lang' => sub { ... } be? I don't understand this. I don't have a route like that. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Fri, Jul 5, 2013 at 12:19 PM, Pedro Melo <melo@simplicidade.org> wrote:
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
That is sort of the crux of the question. Are the templates different? Or is the logic different? The various suggestions for getting language information out of the request path would be my inclination if I had to do this. David -- David Golden <xdg@xdg.me> Take back your inbox! → http://www.bunchmail.com/ Twitter/IRC: @xdg
Hi, On Fri, Jul 5, 2013 at 6:51 PM, David Golden <xdg@xdg.me> wrote:
On Fri, Jul 5, 2013 at 12:19 PM, Pedro Melo <melo@simplicidade.org> wrote:
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
That is sort of the crux of the question. Are the templates different? Or is the logic different?
Only the templates are different, the logic is the same. The various suggestions for getting language information out of the
request path would be my inclination if I had to do this.
Yeah, getting to that conclusion myself... Thanks, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Hi,
I'm being asked to write a webapp for a site that will have three versions for, one for each language.
The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Hi, i know that this could sound like a bizarre coincidence, but i released just this evening on github a little plugin to manage multilanguage sites: https://github.com/cym0n/Dancer2-Plugin-Multilang I want to use it on a site I'm working on, but it's still under testing so feel free to use it as you wish. I'd be glad to receive any feedback about it so to improve it as much as possibile. I want also to put it on CPAN, but for now I think i'll take some time to try it a bit.. -- Cymon Coniglio domina, http://www.therabbit.it
Hi, On Fri, Jul 5, 2013 at 7:44 PM, Cymon <cymon.ML@gmail.com> wrote:
I'm being asked to write a webapp for a site that will have three versions for, one for each language.
The current idea is to use http://site.tld/en/, http://site.tld/de/ and http://site.tld/fr/.
I'll need to think this over on how to do this with Dancer2, but I want to reuse as much as possible of the routes between the three sites.
Hi, i know that this could sound like a bizarre coincidence, but i released just this evening on github a little plugin to manage multilanguage sites:
https://github.com/cym0n/Dancer2-Plugin-Multilang
I want to use it on a site I'm working on, but it's still under testing so feel free to use it as you wish. I'd be glad to receive any feedback about it so to improve it as much as possibile.
hmms.. The code looks sane. I'll give it a try, it seems to be exactly what I'm looking for. Thanks, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (5)
-
Cymon -
David Golden -
Henk van Oers -
Pedro Melo -
Yanick Champoux