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 --