Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make it works with rails 3.1.0rc4

  • Loading branch information...
commit c6c8db6a2c775fcd69e10bf9568c67abc1e55ef3 1 parent 0bfe59d
guillaume authored
View
2  Gemfile
@@ -1,3 +1,3 @@
source "http://rubygems.org"
-gem "rails", '3.0.7'
+gem "rails", '3.1.0rc4'
gem 'rspec', '>=2.5.0'
View
118 Gemfile.lock
@@ -1,65 +1,76 @@
GEM
remote: http://rubygems.org/
specs:
- abstract (1.0.0)
- actionmailer (3.0.7)
- actionpack (= 3.0.7)
- mail (~> 2.2.15)
- actionpack (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.5.0)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.14)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.7)
- activesupport (= 3.0.7)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activeresource (3.0.7)
- activemodel (= 3.0.7)
- activesupport (= 3.0.7)
- activesupport (3.0.7)
- arel (2.0.10)
- builder (2.1.2)
+ actionmailer (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ mail (~> 2.3.0)
+ actionpack (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.0)
+ rack-cache (~> 1.0.1)
+ rack-mount (~> 0.8.1)
+ rack-test (~> 0.6.0)
+ sprockets (~> 2.0.0.beta.10)
+ tzinfo (~> 0.3.27)
+ activemodel (3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ bcrypt-ruby (~> 2.1.4)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ arel (~> 2.1.1)
+ tzinfo (~> 0.3.27)
+ activeresource (3.1.0.rc4)
+ activemodel (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ activesupport (3.1.0.rc4)
+ multi_json (~> 1.0)
+ arel (2.1.3)
+ bcrypt-ruby (2.1.4)
+ builder (3.0.0)
diff-lcs (1.1.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- i18n (0.5.0)
- mail (2.2.19)
- activesupport (>= 2.3.6)
+ erubis (2.7.0)
+ hike (1.1.0)
+ i18n (0.6.0)
+ mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
+ multi_json (1.0.3)
polyglot (0.3.1)
- rack (1.2.3)
- rack-mount (0.6.14)
+ rack (1.3.0)
+ rack-cache (1.0.2)
+ rack (>= 0.4)
+ rack-mount (0.8.1)
rack (>= 1.0.0)
- rack-test (0.5.7)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.0)
rack (>= 1.0)
- rails (3.0.7)
- actionmailer (= 3.0.7)
- actionpack (= 3.0.7)
- activerecord (= 3.0.7)
- activeresource (= 3.0.7)
- activesupport (= 3.0.7)
+ rails (3.1.0.rc4)
+ actionmailer (= 3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activerecord (= 3.1.0.rc4)
+ activeresource (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
bundler (~> 1.0)
- railties (= 3.0.7)
- railties (3.0.7)
- actionpack (= 3.0.7)
- activesupport (= 3.0.7)
+ railties (= 3.1.0.rc4)
+ railties (3.1.0.rc4)
+ actionpack (= 3.1.0.rc4)
+ activesupport (= 3.1.0.rc4)
+ rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
- thor (~> 0.14.4)
- rake (0.9.0)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.8)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
@@ -68,14 +79,19 @@ GEM
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
+ sprockets (2.0.0.beta.10)
+ hike (~> 1.0)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
+ tilt (1.3.2)
treetop (1.4.9)
polyglot (>= 0.3.1)
- tzinfo (0.3.27)
+ tzinfo (0.3.29)
PLATFORMS
ruby
DEPENDENCIES
- rails (= 3.0.7)
+ rails (= 3.1.0rc4)
rspec (>= 2.5.0)
View
13 lib/i18n_routing_rails3.rb
@@ -115,8 +115,8 @@ def nested_deep
# On Routing::Mapper initialization (when doing Application.routes.draw do ...)
# prepare routing system to be i18n ready
- def initialize(*args)
- super
+ def initialize_with_i18n_routing(*args)
+ initialize_without_i18n_routing(*args)
# Add i18n_locale as valid conditions for Rack::Mount / And add also :locale, as Rails 3.0.4 removed it ...
@valid_conditions = @set.instance_eval { @set }.instance_eval { @valid_conditions }
@@ -238,6 +238,7 @@ def create_globalized_resources(type, *resources, &block)
# Alias methods in order to handle i18n routes
def self.included(mod)
+ mod.send :alias_method_chain, :initialize, :i18n_routing
mod.send :alias_method_chain, :resource, :i18n_routing
mod.send :alias_method_chain, :resources, :i18n_routing
@@ -372,7 +373,13 @@ def self.included(mod)
# During route initialization, if a condition i18n_locale is present
# Delete it, and store it in @locale
def initialize_with_i18n_routing(app, conditions, defaults, name)
- @locale = conditions[:i18n_locale] ? conditions.delete(:i18n_locale).source.to_sym : nil
+ @locale = if conditions.key?(:i18n_locale)
+ c = conditions.delete(:i18n_locale)
+ # In rails 3.0 it's a regexp otherwise it's a string, so we need to call source on the regexp
+ (c.respond_to?(:source) ? c.source : c).to_sym
+ else
+ nil
+ end
initialize_without_i18n_routing(app, conditions, defaults, name)
end
View
34 spec/i18n_routing/i18n_spec.rb
@@ -369,26 +369,28 @@ def url_for(opts)
end
- context 'routes with scope' do
+ if rails3?
+ context 'routes with scope' do
- before do
- I18n.locale = 'de'
- end
+ before do
+ I18n.locale = 'de'
+ end
- it "should translate the scope too" do
- routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
- # Scoping is not yet supported on resources ...
- #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/weshs"
- end
+ it "should translate the scope too" do
+ routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
+ # Scoping is not yet supported on resources ...
+ #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/weshs"
+ end
- it "should translate the scope too and even in french!" do
- I18n.locale = 'fr'
- routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
- # Scoping is not yet supported on resources ...
- #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}"
- #routes.send(:wesh_in_wesh_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}/#{I18n.t :in_weshs, :scope => :resources}"
- end
+ it "should translate the scope too and even in french!" do
+ I18n.locale = 'fr'
+ routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
+ # Scoping is not yet supported on resources ...
+ #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}"
+ #routes.send(:wesh_in_wesh_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}/#{I18n.t :in_weshs, :scope => :resources}"
+ end
+ end
end
context 'locale with a dash (pt-br)' do
Please sign in to comment.
Something went wrong with that request. Please try again.