Browse files

Translated routes reordered to give preference to the default locale

  • Loading branch information...
1 parent 50ebd65 commit c402ef27ff0699d1fddbe94f2054c7cdd016f51b @raul committed Nov 28, 2008
Showing with 6 additions and 4 deletions.
  1. +3 −2 lib/translate_routes.rb
  2. +3 −2 sample_app/vendor/plugins/translate_routes/lib/translate_routes.rb
View
5 lib/translate_routes.rb
@@ -112,8 +112,9 @@ def self.translate_current_routes
end
- # apply all new routes
- Routes.routes = new_routes
+ # apply new routes, giving preference to the default locale
+ default_locale_routes = new_routes.select{ |r| r.requirements[:locale] == default_locale }
+ Routes.routes = (default_locale_routes + new_routes).uniq!
new_named_routes.each { |name, r| Routes.named_routes.add name, r }
add_locale_suffix_helper
View
5 sample_app/vendor/plugins/translate_routes/lib/translate_routes.rb
@@ -112,8 +112,9 @@ def self.translate_current_routes
end
- # apply all new routes
- Routes.routes = new_routes
+ # apply new routes, giving preference to the default locale
+ default_locale_routes = new_routes.select{ |r| r.requirements[:locale] == default_locale }
+ Routes.routes = (default_locale_routes + new_routes).uniq!
new_named_routes.each { |name, r| Routes.named_routes.add name, r }
add_locale_suffix_helper

0 comments on commit c402ef2

Please sign in to comment.