i18n_routing 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/Gemfile.lock +67 -51
- data/MIT-LICENSE +0 -0
- data/README.rdoc +0 -0
- data/Rakefile +0 -0
- data/init.rb +0 -0
- data/lib/i18n_routing.rb +0 -0
- data/lib/i18n_routing_rails3.rb +13 -4
- data/spec/i18n_routing/i18n_spec.rb +31 -0
- data/spec/locales/de.yml +5 -0
- data/spec/locales/fr.yml +5 -0
- data/spec/spec_helper.rb +0 -0
- metadata +4 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,65 +1,76 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rack (~> 1.
|
15
|
-
rack-mount (~> 0.
|
16
|
-
rack-test (~> 0.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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.
|
35
|
-
|
36
|
-
i18n (0.
|
37
|
-
mail (2.
|
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.
|
45
|
-
rack-
|
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-
|
53
|
+
rack-ssl (1.3.2)
|
54
|
+
rack
|
55
|
+
rack-test (0.6.0)
|
48
56
|
rack (>= 1.0)
|
49
|
-
rails (3.0.
|
50
|
-
actionmailer (= 3.0.
|
51
|
-
actionpack (= 3.0.
|
52
|
-
activerecord (= 3.0.
|
53
|
-
activeresource (= 3.0.
|
54
|
-
activesupport (= 3.0.
|
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.
|
57
|
-
railties (3.0.
|
58
|
-
actionpack (= 3.0.
|
59
|
-
activesupport (= 3.0.
|
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
|
-
|
62
|
-
|
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.
|
90
|
+
tzinfo (0.3.29)
|
75
91
|
|
76
92
|
PLATFORMS
|
77
93
|
ruby
|
78
94
|
|
79
95
|
DEPENDENCIES
|
80
|
-
rails (= 3.
|
96
|
+
rails (= 3.1.0rc4)
|
81
97
|
rspec (>= 2.5.0)
|
data/MIT-LICENSE
CHANGED
File without changes
|
data/README.rdoc
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/init.rb
CHANGED
File without changes
|
data/lib/i18n_routing.rb
CHANGED
File without changes
|
data/lib/i18n_routing_rails3.rb
CHANGED
@@ -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
|
119
|
-
|
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
|
-
|
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 =
|
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
|
data/spec/locales/de.yml
ADDED
data/spec/locales/fr.yml
CHANGED
@@ -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'
|
data/spec/spec_helper.rb
CHANGED
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.
|
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-
|
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.
|
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 !
|