aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/routing_filters.rb9
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