Language code in the URL

Cheers fellow developers,

in our application we would like to include a language code in the URL’s
of at least some resources, mainly for SEO reasons (Google should index
several language versions of the same page so users can find them). Our
ultimate choice for a scheme looks like this:

/foobars/123.en.html
/foobars/123.fr.html

This displays neatly what it’s all about: in contrast with a choice like
/en/foobars/123.html it correctly suggests that these URL’s are not
pointing to entirely different kinds of resources but variants of the
same one. It also seems to be easier to achieve by a generic, DRY
solution.

My question is: is this somehow possible without major tweakings in
Rails internals?
I’d also note that we would like to avoid external
rewriting for obvious portability reasons.

Hey …

/foobars/123.en.html
/foobars/123.fr.html

My question is: is this somehow possible without major tweakings in
Rails internals?
I’d also note that we would like to avoid external
rewriting for obvious portability reasons.

thats exactly a topic of a talk at the next rails conference in
berlin later this year :wink:

yes it is possible, but not without some serious tweaking.
especially if you want to be RESTful. Basically you need to
extend the routed to not only support :format, but :locale.:format.

I’m actually working on that right now, but it’s far from stable.
I hope to release this as a plugin in the future, you can get
a first glimpse at it right here:

http://bugs.omdb.org/browser/branches/2007.1/vendor/plugins/mlcache/
lib/actionpack_ext.rb

this will support extensions to RESTful routes, as well as updated
page and fragment caching to respect the locale set for
the current request.

Ben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs