i18n_routing 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source "http://rubygems.org"
2
- gem "rails", '3.0.6'
2
+ gem "rails", '3.1.0rc4'
3
3
  gem 'rspec', '>=2.5.0'
@@ -1,65 +1,76 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- abstract (1.0.0)
5
- actionmailer (3.0.6)
6
- actionpack (= 3.0.6)
7
- mail (~> 2.2.15)
8
- actionpack (3.0.6)
9
- activemodel (= 3.0.6)
10
- activesupport (= 3.0.6)
11
- builder (~> 2.1.2)
12
- erubis (~> 2.6.6)
13
- i18n (~> 0.5.0)
14
- rack (~> 1.2.1)
15
- rack-mount (~> 0.6.14)
16
- rack-test (~> 0.5.7)
17
- tzinfo (~> 0.3.23)
18
- activemodel (3.0.6)
19
- activesupport (= 3.0.6)
20
- builder (~> 2.1.2)
21
- i18n (~> 0.5.0)
22
- activerecord (3.0.6)
23
- activemodel (= 3.0.6)
24
- activesupport (= 3.0.6)
25
- arel (~> 2.0.2)
26
- tzinfo (~> 0.3.23)
27
- activeresource (3.0.6)
28
- activemodel (= 3.0.6)
29
- activesupport (= 3.0.6)
30
- activesupport (3.0.6)
31
- arel (2.0.9)
32
- builder (2.1.2)
4
+ actionmailer (3.1.0.rc4)
5
+ actionpack (= 3.1.0.rc4)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.0.rc4)
8
+ activemodel (= 3.1.0.rc4)
9
+ activesupport (= 3.1.0.rc4)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.0)
14
+ rack-cache (~> 1.0.1)
15
+ rack-mount (~> 0.8.1)
16
+ rack-test (~> 0.6.0)
17
+ sprockets (~> 2.0.0.beta.10)
18
+ tzinfo (~> 0.3.27)
19
+ activemodel (3.1.0.rc4)
20
+ activesupport (= 3.1.0.rc4)
21
+ bcrypt-ruby (~> 2.1.4)
22
+ builder (~> 3.0.0)
23
+ i18n (~> 0.6)
24
+ activerecord (3.1.0.rc4)
25
+ activemodel (= 3.1.0.rc4)
26
+ activesupport (= 3.1.0.rc4)
27
+ arel (~> 2.1.1)
28
+ tzinfo (~> 0.3.27)
29
+ activeresource (3.1.0.rc4)
30
+ activemodel (= 3.1.0.rc4)
31
+ activesupport (= 3.1.0.rc4)
32
+ activesupport (3.1.0.rc4)
33
+ multi_json (~> 1.0)
34
+ arel (2.1.3)
35
+ bcrypt-ruby (2.1.4)
36
+ builder (3.0.0)
33
37
  diff-lcs (1.1.2)
34
- erubis (2.6.6)
35
- abstract (>= 1.0.0)
36
- i18n (0.5.0)
37
- mail (2.2.16)
38
- activesupport (>= 2.3.6)
38
+ erubis (2.7.0)
39
+ hike (1.1.0)
40
+ i18n (0.6.0)
41
+ mail (2.3.0)
39
42
  i18n (>= 0.4.0)
40
43
  mime-types (~> 1.16)
41
44
  treetop (~> 1.4.8)
42
45
  mime-types (1.16)
46
+ multi_json (1.0.3)
43
47
  polyglot (0.3.1)
44
- rack (1.2.2)
45
- rack-mount (0.6.14)
48
+ rack (1.3.0)
49
+ rack-cache (1.0.2)
50
+ rack (>= 0.4)
51
+ rack-mount (0.8.1)
46
52
  rack (>= 1.0.0)
47
- rack-test (0.5.7)
53
+ rack-ssl (1.3.2)
54
+ rack
55
+ rack-test (0.6.0)
48
56
  rack (>= 1.0)
49
- rails (3.0.6)
50
- actionmailer (= 3.0.6)
51
- actionpack (= 3.0.6)
52
- activerecord (= 3.0.6)
53
- activeresource (= 3.0.6)
54
- activesupport (= 3.0.6)
57
+ rails (3.1.0.rc4)
58
+ actionmailer (= 3.1.0.rc4)
59
+ actionpack (= 3.1.0.rc4)
60
+ activerecord (= 3.1.0.rc4)
61
+ activeresource (= 3.1.0.rc4)
62
+ activesupport (= 3.1.0.rc4)
55
63
  bundler (~> 1.0)
56
- railties (= 3.0.6)
57
- railties (3.0.6)
58
- actionpack (= 3.0.6)
59
- activesupport (= 3.0.6)
64
+ railties (= 3.1.0.rc4)
65
+ railties (3.1.0.rc4)
66
+ actionpack (= 3.1.0.rc4)
67
+ activesupport (= 3.1.0.rc4)
68
+ rack-ssl (~> 1.3.2)
60
69
  rake (>= 0.8.7)
61
- thor (~> 0.14.4)
62
- rake (0.8.7)
70
+ rdoc (~> 3.4)
71
+ thor (~> 0.14.6)
72
+ rake (0.9.2)
73
+ rdoc (3.8)
63
74
  rspec (2.5.0)
64
75
  rspec-core (~> 2.5.0)
65
76
  rspec-expectations (~> 2.5.0)
@@ -68,14 +79,19 @@ GEM
68
79
  rspec-expectations (2.5.0)
69
80
  diff-lcs (~> 1.1.2)
70
81
  rspec-mocks (2.5.0)
82
+ sprockets (2.0.0.beta.10)
83
+ hike (~> 1.0)
84
+ rack (~> 1.0)
85
+ tilt (~> 1.1, != 1.3.0)
71
86
  thor (0.14.6)
87
+ tilt (1.3.2)
72
88
  treetop (1.4.9)
73
89
  polyglot (>= 0.3.1)
74
- tzinfo (0.3.26)
90
+ tzinfo (0.3.29)
75
91
 
76
92
  PLATFORMS
77
93
  ruby
78
94
 
79
95
  DEPENDENCIES
80
- rails (= 3.0.6)
96
+ rails (= 3.1.0rc4)
81
97
  rspec (>= 2.5.0)
File without changes
File without changes
data/Rakefile CHANGED
File without changes
data/init.rb CHANGED
File without changes
File without changes
@@ -115,8 +115,8 @@ module I18nRouting
115
115
 
116
116
  # On Routing::Mapper initialization (when doing Application.routes.draw do ...)
117
117
  # prepare routing system to be i18n ready
118
- def initialize(*args)
119
- super
118
+ def initialize_with_i18n_routing(*args)
119
+ initialize_without_i18n_routing(*args)
120
120
 
121
121
  # Add i18n_locale as valid conditions for Rack::Mount / And add also :locale, as Rails 3.0.4 removed it ...
122
122
  @valid_conditions = @set.instance_eval { @set }.instance_eval { @valid_conditions }
@@ -238,6 +238,7 @@ module I18nRouting
238
238
 
239
239
  # Alias methods in order to handle i18n routes
240
240
  def self.included(mod)
241
+ mod.send :alias_method_chain, :initialize, :i18n_routing
241
242
  mod.send :alias_method_chain, :resource, :i18n_routing
242
243
  mod.send :alias_method_chain, :resources, :i18n_routing
243
244
 
@@ -294,7 +295,9 @@ module I18nRouting
294
295
  tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
295
296
  !ts.blank? && I18nRouting.translation_for(ts, :named_routes_path) || ts
296
297
 
297
- @localized_path = File.join((@scope[:path] || ''), tp).gsub(/\/$/, '')
298
+ localized_scope = I18nRouting.translation_for(@scope[:path].gsub(/\//, ''), :scopes) if @scope[:path]
299
+ path = localized_scope ? '/' << localized_scope : @scope[:path]
300
+ @localized_path = File.join((path || ''), tp).gsub(/\/$/, '')
298
301
 
299
302
  # If a translated path exists, set localized infos
300
303
  if !@localized_path.blank? and @localized_path != @path
@@ -370,7 +373,13 @@ module I18nRouting
370
373
  # During route initialization, if a condition i18n_locale is present
371
374
  # Delete it, and store it in @locale
372
375
  def initialize_with_i18n_routing(app, conditions, defaults, name)
373
- @locale = conditions[:i18n_locale] ? conditions.delete(:i18n_locale).source.to_sym : nil
376
+ @locale = if conditions.key?(:i18n_locale)
377
+ c = conditions.delete(:i18n_locale)
378
+ # In rails 3.0 it's a regexp otherwise it's a string, so we need to call source on the regexp
379
+ (c.respond_to?(:source) ? c.source : c).to_sym
380
+ else
381
+ nil
382
+ end
374
383
  initialize_without_i18n_routing(app, conditions, defaults, name)
375
384
  end
376
385
 
@@ -101,6 +101,13 @@ describe :localized_routes do
101
101
  end
102
102
  end
103
103
 
104
+ scope "german" do
105
+ match "/sausage" => "meal#show", :as => :german_sausage
106
+ resources :weshs do
107
+ resources :in_weshs
108
+ end
109
+ end
110
+
104
111
  resources :universes do
105
112
  resources :galaxies do
106
113
  resources :planets do
@@ -362,6 +369,30 @@ describe :localized_routes do
362
369
 
363
370
  end
364
371
 
372
+ if rails3?
373
+ context 'routes with scope' do
374
+
375
+ before do
376
+ I18n.locale = 'de'
377
+ end
378
+
379
+ it "should translate the scope too" do
380
+ routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
381
+ # Scoping is not yet supported on resources ...
382
+ #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/weshs"
383
+ end
384
+
385
+ it "should translate the scope too and even in french!" do
386
+ I18n.locale = 'fr'
387
+ routes.send(:german_sausage_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :sausage, :scope => :named_routes_path}"
388
+ # Scoping is not yet supported on resources ...
389
+ #routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}"
390
+ #routes.send(:wesh_in_wesh_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}/#{I18n.t :in_weshs, :scope => :resources}"
391
+ end
392
+
393
+ end
394
+ end
395
+
365
396
  context 'locale with a dash (pt-br)' do
366
397
 
367
398
  before do
@@ -0,0 +1,5 @@
1
+ de:
2
+ scopes:
3
+ german: 'deutsche'
4
+ named_routes_path:
5
+ sausage: 'bratwurst'
@@ -23,14 +23,19 @@ fr:
23
23
  bars: bars_fr
24
24
  empty_resources: ''
25
25
  empty__resources: ''
26
+ weshs: 'fr_weshs'
27
+ in_weshs: 'fr_in_weshs'
26
28
  resource:
27
29
  foo: foo_fr
28
30
  foofoo: froufrou
29
31
  contact: 'contactez-nous'
32
+ scopes:
33
+ german: 'allemand'
30
34
  named_routes_path:
31
35
  about: 'a-propos'
32
36
  'welcome/to/our/page': 'bienvenue/sur/notre/site' # no idea about french translation ;-) --R
33
37
  empty: ''
38
+ sausage: 'saucisse'
34
39
  path_names:
35
40
  new: 'nouveau'
36
41
  edit: 'edition'
File without changes
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: i18n_routing
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.7
5
+ version: 0.4.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Guillaume Luccisano
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-17 00:00:00 -07:00
13
+ date: 2011-07-13 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -38,6 +38,7 @@ files:
38
38
  - lib/i18n_routing_rails2.rb
39
39
  - lib/i18n_routing_rails3.rb
40
40
  - spec/i18n_routing/i18n_spec.rb
41
+ - spec/locales/de.yml
41
42
  - spec/locales/en.yml
42
43
  - spec/locales/fr.yml
43
44
  - spec/locales/pt-br.yml
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  requirements: []
74
75
 
75
76
  rubyforge_project: i18n_routing
76
- rubygems_version: 1.5.2
77
+ rubygems_version: 1.6.2
77
78
  signing_key:
78
79
  specification_version: 3
79
80
  summary: I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !