diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-07-15 10:44:38 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-07-15 10:44:38 +0100 |
commit | 183b5be4f8e2e7396a32c6d15f6fb5c085ba0889 (patch) | |
tree | 8ab399c250799a8c337aa596e8aeebfd08d9a95f /lib | |
parent | 62b006d959caf95870f9215e56fb3594c585a259 (diff) |
Only prepend locales to paths when there's more than one locale to choose from.
Replaces core "locale" filter with customised one. Fixes #82
Diffstat (limited to 'lib')
-rw-r--r-- | lib/routing_filters.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/routing_filters.rb b/lib/routing_filters.rb new file mode 100644 index 000000000..cdb58e7c1 --- /dev/null +++ b/lib/routing_filters.rb @@ -0,0 +1,9 @@ +module RoutingFilter + class Conditionallyprependlocale < RoutingFilter::Locale + # Override core Locale filter not to prepend locale path segment + # when there's only one locale + def prepend_locale?(locale) + locale && I18n.available_locales.length > 1 && (self.class.include_default_locale? || !default_locale?(locale)) + end + end +end |