[dancer-users] Set interface language via URL path

Pedro Melo melo at simplicidade.org
Mon Jul 8 12:39:23 BST 2013


Hi,

On Fri, Jul 5, 2013 at 5:39 PM, Yanick Champoux <yanick at 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 at simplicidade.org
mailto:melo at simplicidade.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130708/f14dfdf1/attachment.htm>


More information about the dancer-users mailing list