Skip to content

Commit

Permalink
fix routing in some conditions like when i18n is on
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Jul 2, 2010
1 parent 72d3982 commit 1c57572
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vendor/plugins/i18n/lib/i18n_filter.rb
Expand Up @@ -4,7 +4,12 @@ class Locale < Base
def around_recognize(path, env, &block)
if Refinery::I18n.enabled?
locale = nil
path.sub! %r(^/(([a-zA-Z\-_])*)(?=/|$)) do locale = $1; '' end if path !~ %r{^/(refinery|wymiframe)}
if path !~ %r{^/(refinery|wymiframe)} and I18n.locale != I18n.default_locale
path.sub! %r(^/(([a-zA-Z\-_])*)(?=/|$)) do
locale = $1;
''
end
end

returning yield do |params|
params[:locale] = (locale.presence || Refinery::I18n.current_locale) unless I18n.locale == I18n.default_locale
Expand All @@ -18,7 +23,9 @@ def around_generate(*args, &block)
if Refinery::I18n.enabled?
locale = args.extract_options!.delete(:locale) || Refinery::I18n.current_locale
returning yield do |result|
result.sub!(%r(^(http.?://[^/]*)?(.*))){ "#{$1}/#{locale}#{$2}" } if (locale != I18n.default_locale and result !~ %r{^/(refinery|wymiframe)})
if (locale != I18n.default_locale and result !~ %r{^/(refinery|wymiframe)})
result.sub!(%r(^(http.?://[^/]*)?(.*))){ "#{$1}/#{locale}#{$2}" }
end
result
end
else
Expand Down

0 comments on commit 1c57572

Please sign in to comment.