<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 5, 2013 at 5:39 PM, Yanick Champoux <span dir="ltr"><<a href="mailto:yanick@babyl.dyndns.org" target="_blank">yanick@babyl.dyndns.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, Jul 05, 2013 at 05:19:37PM +0100, Pedro Melo wrote:<br>
> Hi,<br>
><br>
> I'm being asked to write a webapp for a site that will have three versions<br>
> for, one for each language.<br>
><br>
> The current idea is to use <a href="http://site.tld/en/" target="_blank">http://site.tld/en/</a>, <a href="http://site.tld/de/" target="_blank">http://site.tld/de/</a> and<br>
> <a href="http://site.tld/fr/" target="_blank">http://site.tld/fr/</a>.<br>
><br>
> I'll need to think this over on how to do this with Dancer2, but I want to<br>
> reuse as much as possible of the routes between the three sites.<br>
><br>
> Does anybody did this before and can share a strategy? My current best<br>
> solution for this would be to had a hook as soon as possible and remove the<br>
> first level path if it matches one of the languages we support and set a<br>
> var for it.<br>
><br>
> Any other suggestions?<br>
<br>
</div>In the same vein:<br>
<br>
use Dancer2;<br>
<br>
<br>
get '/*/**' => sub {<br>
var lang => (splat)[0];<br>
pass;<br>
};<br>
<br>
prefix '/*';<br>
<br>
my %greeting = (<br>
en => 'howdie',<br>
fr => 'bonjour',<br>
de => 'hallo',<br>
);<br>
<br>
get '/welcome' => sub {<br>
return $greeting{ var 'lang' };<br>
};<br>
<br></blockquote><div><br></div><div style>Yeah, this is similar to what I was playing with...</div><div style> </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Another idea (and I'm just thinking out loud, so take all<br>
here with a grain of salt) could be to have a nginx or apache<br>
reverse proxy taking in the urls /de/*, /fr/*, /en/*, rewrite<br>
them as the prefix-less '*', and pass the language as an<br>
environment variable.<br></blockquote><div><br></div><div style>Also though of that, and I might be going this route. The big disadvantage is that url_for doesn't work properly anymore. </div><div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In the same vein, you could have en.site.tld, fr.site.tld, etc.<br></blockquote><div><br></div><div style>This the client doesn't want. I tried.</div><div style><br></div><div style>Thanks,</div></div>-- <br>Pedro Melo<br>
@pedromelo<br><a href="http://www.simplicidade.org/" target="_blank">http://www.simplicidade.org/</a><br><a href="mailto:xmpp%3Amelo@simplicidade.org" target="_blank">xmpp:melo@simplicidade.org</a><br>mailto:<a href="mailto:melo@simplicidade.org" target="_blank">melo@simplicidade.org</a>
</div></div>