[dancer-users] Set interface language via URL path

Henk van Oers hvo.pm at xs4all.nl
Fri Jul 5 17:54:24 BST 2013


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


More information about the dancer-users mailing list