Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Option for disabling url filter.

New option, `url_filter_enabled`, allows disabling the url filter. Usage:

Refinery::I18n.configure do |config|
  # other config ...
  config.url_filter_enabled = false
end
  • Loading branch information...
commit a2c5b66481db5a73b692479632ddb96bd99bff9d 1 parent d9f5b93
@andreas andreas authored
View
4 lib/refinery/i18n-filter.rb
@@ -2,7 +2,7 @@ module RoutingFilter
class RefineryLocales < Filter
def around_recognize(path, env, &block)
- if ::Refinery::I18n.enabled?
+ if ::Refinery::I18n.url_filter_enabled?
if path =~ %r{^/(#{::Refinery::I18n.locales.keys.join('|')})(/|$)}
path.sub! %r(^/(([a-zA-Z\-_])*)(?=/|$)) do
::I18n.locale = $1
@@ -24,7 +24,7 @@ def around_generate(params, &block)
yield.tap do |result|
result = result.is_a?(Array) ? result.first : result
- if ::Refinery::I18n.enabled? and
+ if ::Refinery::I18n.url_filter_enabled? and
locale != ::Refinery::I18n.default_frontend_locale and
result !~ %r{^/(refinery|wymiframe)}
result.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{locale}#{$2}" }
View
4 lib/refinery/i18n.rb
@@ -50,6 +50,10 @@ def enabled?
config.enabled
end
+ def url_filter_enabled?
+ enabled? && config.url_filter_enabled
+ end
+
def has_locale?(locale)
config.locales.has_key?(locale.try(:to_sym))
end
View
4 lib/refinery/i18n/configuration.rb
@@ -3,7 +3,8 @@ module I18n
include ActiveSupport::Configurable
config_accessor :current_locale, :default_locale, :default_frontend_locale,
- :enabled, :fallbacks_enabled, :frontend_locales, :locales
+ :enabled, :fallbacks_enabled, :frontend_locales, :locales,
+ :url_filter_enabled
self.enabled = true
self.default_locale = :en
@@ -12,5 +13,6 @@ module I18n
self.fallbacks_enabled = true
self.frontend_locales = [self.default_frontend_locale]
self.locales = self.built_in_locales
+ self.url_filter_enabled = true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.