Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid generating duplicate routes? #87

Closed
jensb opened this issue Jan 26, 2015 · 4 comments
Closed

Avoid generating duplicate routes? #87

jensb opened this issue Jan 26, 2015 · 4 comments

Comments

@jensb
Copy link

jensb commented Jan 26, 2015

When using host_locales, many routes get duplicated, e.g. I have

 get '/blah' => 'api/v1/foo#bar', as: :blah_foo

in a localized block in routes.rb. This results in (with available_locales = :de, :en)

    blah_foo_de GET    /de/blah(.:format)      api/v1/foo#bar {:locale=>"de"}
    blah_foo_native_en GET    /blah(.:format)         api/v1/foo#bar {:locale=>"en"}
    blah_foo_native_de GET    /blah(.:format)         api/v1/foo#bar {:locale=>"de"}
    blah_foo_en GET    /blah(.:format)         api/v1/foo#bar {:locale=>"en"}

If both /de/blah and /blah are accessible under the German domain with the same content, this will result in duplicate content penalties in search engines. Can I drop the "native" routes?

@tagliala
Copy link
Collaborator

This should be possible via config.force_locale = true

@lime
Copy link

lime commented Mar 24, 2015

This should be possible via config.force_locale = true

However, the README states:

If host_locales option is set, the following options will be forced (even if you set to true):

@config.generate_unlocalized_routes         = false
@config.generate_unnamed_unlocalized_routes = false
@config.force_locale                        = false
@config.hide_locale                         = false

What's the reasoning behind this? Would being able to set force_locale = true cause any adverse effects?

@tagliala
Copy link
Collaborator

@lime you are right, because I was not and I'm not using this solution for the very same reason.

This is my approach:

route_translator.rb

RouteTranslator.config do |config|
  config.hide_locale = true
end

application_controller.rb

  DOMAIN_LANGUAGE = {
    'it.lvh.me' => :it,
    'en.lvh.me' => :en
  }

  skip_around_action :set_locale_from_url
  around_action :set_site_locale

  def set_site_locale(&block)
    I18n.with_locale DOMAIN_LANGUAGE[request.host], &block
  end

but I'm having other issues, see: #91, #95

@tagliala tagliala mentioned this issue Jan 18, 2016
3 tasks
@tagliala tagliala added this to the 6.0.0 milestone Jul 17, 2017
tagliala added a commit that referenced this issue Jul 21, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87
tagliala added a commit that referenced this issue Jul 21, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87
@tagliala
Copy link
Collaborator

Fixed in the just released 6.0.0.alpha1

tagliala added a commit that referenced this issue Nov 12, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87
tagliala added a commit that referenced this issue Nov 12, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87
tagliala added a commit that referenced this issue Dec 3, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87
tagliala added a commit that referenced this issue Dec 3, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87

Refers to: #171
tagliala added a commit that referenced this issue Dec 3, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87

Close: #171
tagliala added a commit that referenced this issue Dec 3, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fix: #87, #171
tagliala added a commit that referenced this issue Dec 3, 2017
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Feb 5, 2018
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Apr 9, 2018
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Apr 10, 2018
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Jun 7, 2018
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Oct 3, 2018
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Jan 19, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Mar 14, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue May 16, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue May 16, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Dec 26, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Dec 26, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Dec 26, 2019
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
tagliala added a commit that referenced this issue Apr 17, 2020
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
AsgharRaz pushed a commit to AsgharRaz/route_translator that referenced this issue Nov 3, 2020
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes enriclluelles#87 and fixes enriclluelles#171
tagliala added a commit that referenced this issue Jan 13, 2021
The purpose of this refactor is to avoid duplicate routes.

Previously, route_translator allowed duplicate routes `/cars` and
`/en/cars` under the `en` domain when `host_locales` was set.

Fixes #87 and fixes #171
@tagliala tagliala reopened this Jan 13, 2021
@tagliala tagliala removed this from the 7.0.0 milestone Jan 13, 2021
@tagliala tagliala added this to the 10.0 milestone Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants