francesc / rails-translate-routes

MIT License
147 stars 50 forks source link

Option for keeping access to untranslated routes (keep_untranslated_routes) #17

Closed nicoarbogast closed 12 years ago

nicoarbogast commented 12 years ago

I added this option to allow the following routes structure

default_locale = :en

/en/translated-products /fr/translated-produits /products

I used this config in production in a Rails 3.1 project and just updated it to fit 3.2 requirements.

francesc commented 12 years ago

Are you sure you want this url structure? You'll get some duplicate content on: /en/translated-products - /products and you can't do a permanent redirection header on /products to avoid it as it changes everytime depending on the client language.

nicoarbogast commented 12 years ago

Hi,

Thank you for your reply. Actually the structure I get is the following:

/raw_resource_name /en/translated_route_for_resource_in_en /fr/translated_route_for_resource_in_fr /es/translated_route_for_resource_in_es ...

Then I redirect /raw_resource_name to translated routes if ( !request.xhr? + whatever conditions )

I have an app in prod with this config, with no duplicate and no issue with redirections for the moment.

I like it because it allows me to build ajax urls, and basic api calls using the raw_resource_name. (Another solution would be to use I18n in my javascript for building request urls, I agree, but I find it simpler with this method).

Please tell me if you think there are better ways of designing this. Thanx Nico

francesc commented 12 years ago

Will be on next release on a few hours, make basic testing, if you find any problem tell me.

nicoarbogast commented 12 years ago

Thanks a lot ! Tested and seems to be working great !