[Catalyst] Language selection in URLs

Bill Moseley moseley at hank.org
Sun Nov 15 16:43:58 GMT 2009


On Sun, Nov 15, 2009 at 7:23 AM, Joel Bernstein <joel at fysh.org> wrote:

> On 15 Nov 2009, at 15:06, Bill Moseley wrote:
>
> >
> > What's your preferred approach to specifying a language tag in a URL?  =
Is
> there strong argument for one over the other?
> >
> > http://example.com/en_us/path/to/some/index.html # language prefix
> >
> > http://example.com/path/to/some/index.html?lang=3Den_us
>
> No no no! Allow the client and server to negotiate what content to serve
> for the resource identified. As a URI to a resource which may vary accord=
ing
> to many dimensions, /path/to/some/content is fine.
>

I use that as a fallback, but in practice auto-detection doesn't work as
well as one would hope.   In fact I think I disabled that code because of
all the headaches.  Turns out the browser is not very good at understanding
the user running the browser at that moment, or the user's preference for a
given page.    We also had problems with caching of pages in the wrong
language.  At one point we would set a flag in the session, too, but that
had problems (with proxy caching IIRC).



> If you really must stick it in the URL, I'd go for something like:
> /path/to/content/en
> /path/to/content/pt_BR
> etc
>

I prefer the prefix to that.  Makes it transparent to the applicaiton and
relative URLs work.



>
> A better question is: what kind of problems are you solving where
> server-driven or agent-driven content negotiation as described in the HTTP
> 1.1 RFC (an excellent and very readable document, honestly) are
> insufficient?
>


The quesiton was just between using a query parameter vs. a path segment.



-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20091115/2bf82=
b28/attachment.htm


More information about the Catalyst mailing list