kwi / i18n_routing

I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !
MIT License
228 stars 48 forks source link

Both original and translated routes exist: Duplicate Content #26

Open jensb opened 13 years ago

jensb commented 13 years ago

Hello,

when I use your plugin, both the original and the translated routes exist. This is a problem because it creates duplicate content, which is bad for SEO.

Is it possible to have only the translated routes, and remove the original routes, when the locale is set to a language other than the default?

Thanks!

juhat commented 13 years ago

I had the same problem - but it can be solved easily with a redirect call. Redirect all stuff to the new place. You can use parameters in rails redirects, so you can redirect all contents easily.

jensb commented 13 years ago

The issue is not really solved with a redirect. It works for users, but when pages are indexed by search engines, this can destroy your ranking (think "duplicate content"). Pages which don't exist or contain duplicate content should return 404.

How did you solve this?

juhat commented 13 years ago

I see your point. What is the perfect solution to this?

jensb commented 13 years ago

This is simple: When adding translated routes, remove the original routes from the routing table.

However, I do not know how to do this in i18n-routing ... :)

rogercampos commented 12 years ago

I also had this problem, the solution I found is to simply add a constraint that checks the locale of the request vs the current locale at the time the definition is executed:

localized([:es, :ca, :en]) do
  scope "/:i18n_locale", :constraints => {:i18n_locale => I18n.locale} do
  end
end

Then make sure you set the locale looking first for the i18n_locale attribute. This is what I have:

def set_locale
  I18n.locale = params[:i18n_locale] || params[:locale]
end

Because I only have a subset of all my routes translated.