Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 4 Compatibility #44

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.gem
.loadpath
.project
.project
.DS_Store
*~
2 changes: 2 additions & 0 deletions lib/i18n_routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

if Rails.version < '3'
require 'i18n_routing_rails2'
elsif Rails.version >= '4'
require 'i18n_routing_rails4'
elsif Rails.version >= '3.2'
require 'i18n_routing_rails32'
else
Expand Down
8 changes: 4 additions & 4 deletions lib/i18n_routing_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module I18nRouting
def self.locale_escaped(locale)
locale.to_s.downcase.gsub('-', '_')
end

# Return the correct translation for given values
def self.translation_for(name, type = :resources, option = nil)
# First, if an option is given, try to get the translation in the routes scope
Expand All @@ -16,7 +16,7 @@ def self.translation_for(name, type = :resources, option = nil)
else
default = "{name}Noi18nRoutingTranslation"

# Try to get the translation in routes namescope first
# Try to get the translation in routes namescope first
t = I18n.t(:as, :scope => "routes.#{name}", :default => default)

return t if t and t != default
Expand All @@ -32,12 +32,12 @@ def self.translation_for(name, type = :resources, option = nil)
# Return path names hash for given resource
def self.path_names(name, options)
h = (options[:path_names] || {}).dup

path_names = DefaultPathNames
PathNamesKeys.each do |v|
path_names += options[v].keys if options[v] and Hash === options[v]
end

path_names.each do |pn|
n = translation_for(name, :path_names, pn)
n = nil if n == pn.to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n_routing_rails32.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,4 @@ def score_with_i18n_routing constraints
end

ActionDispatch::Routing::Mapper.send :include, I18nRouting::Mapper
Journey::Route.send :include, I18nRouting::JourneyRoute
Journey::Route.send :include, I18nRouting::JourneyRoute
Loading