i18n_routing 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/lib/i18n_routing_rails31.rb +24 -22
- data/lib/i18n_routing_rails32.rb +24 -22
- data/spec/i18n_routing/i18n_spec.rb +39 -30
- metadata +11 -6
data/README.rdoc
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
I18n_routing is a plugin for Ruby on Rails that lets you easily translate your routes trough the I18n api included in Rails since version 2.2
|
4
4
|
|
5
|
-
All necessary
|
5
|
+
All necessary information is available on the wiki: http://wiki.github.com/kwi/i18n_routing
|
6
6
|
|
7
|
-
For
|
7
|
+
For your questions, use the i18_routing google group: http://groups.google.com/group/i18n-routing
|
8
8
|
|
9
9
|
Works with Rails 2.3, 3.0, 3.1 and 3.2
|
10
10
|
|
data/lib/i18n_routing_rails31.rb
CHANGED
@@ -7,7 +7,7 @@ module I18nRouting
|
|
7
7
|
module Mapper
|
8
8
|
|
9
9
|
private
|
10
|
-
|
10
|
+
|
11
11
|
# Just create a Mapper:Resource with given parameters
|
12
12
|
def resource_from_params(type, *resources)
|
13
13
|
res = resources.clone
|
@@ -17,7 +17,7 @@ module I18nRouting
|
|
17
17
|
|
18
18
|
type == :resource ? ActionDispatch::Routing::Mapper::SingletonResource.new(r, options.dup) : ActionDispatch::Routing::Mapper::Resource.new(r, options.dup)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# Localize a resources or a resource
|
22
22
|
def localized_resources(type = :resources, *resources, &block)
|
23
23
|
localizable_route = nil
|
@@ -42,7 +42,7 @@ module I18nRouting
|
|
42
42
|
opts = options.dup
|
43
43
|
opts[:path] = localized_path
|
44
44
|
opts[:controller] ||= r.to_s.pluralize
|
45
|
-
|
45
|
+
|
46
46
|
resource = resource_from_params(type, r, opts.dup)
|
47
47
|
|
48
48
|
res = ["#{I18nRouting.locale_escaped(locale)}_#{r}".to_sym, opts]
|
@@ -53,7 +53,7 @@ module I18nRouting
|
|
53
53
|
scope(:constraints => constraints, :path_names => I18nRouting.path_names(resource.name, @scope)) do
|
54
54
|
localized_branch(locale) do
|
55
55
|
send(type, *res) do
|
56
|
-
|
56
|
+
|
57
57
|
# In the resource(s) block, we need to keep and restore some context :
|
58
58
|
if block
|
59
59
|
old_name = @scope[:i18n_real_resource_name]
|
@@ -92,7 +92,7 @@ module I18nRouting
|
|
92
92
|
# If yes, localizable is a name, or a Mapper::Resource
|
93
93
|
# Can take a block, if so, save the current context, set the new
|
94
94
|
# Call the block, then restore the old context and return the block return
|
95
|
-
def set_localizable_route(localizable)
|
95
|
+
def set_localizable_route(localizable)
|
96
96
|
if block_given?
|
97
97
|
old = @set.named_routes.localizable
|
98
98
|
@set.named_routes.set_localizable_route(localizable)
|
@@ -103,11 +103,11 @@ module I18nRouting
|
|
103
103
|
@set.named_routes.set_localizable_route(localizable)
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def localizable_route
|
108
108
|
@set.named_routes.localizable
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
# Return the aproximate deep in scope level
|
112
112
|
def nested_deep
|
113
113
|
(@scope and Array === @scope[:nested_deep] and @scope[:scope_level]) ? @scope[:nested_deep].size : 0
|
@@ -156,7 +156,7 @@ module I18nRouting
|
|
156
156
|
I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml')]).flatten.uniq
|
157
157
|
@i18n_routing_path_set = true
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
old_value = @locales
|
161
161
|
@locales = locales
|
162
162
|
@i18n_verbose ||= opts.delete(:verbose)
|
@@ -164,7 +164,7 @@ module I18nRouting
|
|
164
164
|
ensure
|
165
165
|
@locales = old_value
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
# Create a branch for create routes in the specified locale
|
169
169
|
def localized_branch(locale)
|
170
170
|
set_localizable_route(nil) do
|
@@ -176,7 +176,7 @@ module I18nRouting
|
|
176
176
|
@localized_branch = old
|
177
177
|
end
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
# Set we do not want to localize next resource
|
181
181
|
def skip_localization
|
182
182
|
old = @skip_localization
|
@@ -227,7 +227,7 @@ module I18nRouting
|
|
227
227
|
|
228
228
|
super
|
229
229
|
end
|
230
|
-
|
230
|
+
|
231
231
|
def create_globalized_resources(type, *resources, &block)
|
232
232
|
#puts "#{' ' * nested_deep}Call #{type} : #{resources.inspect} (#{@locales.inspect}) (#{@localized_branch}) (#{@skip_localization})"
|
233
233
|
|
@@ -254,16 +254,16 @@ module I18nRouting
|
|
254
254
|
send("#{type}_without_i18n_routing".to_sym, *resources, &block)
|
255
255
|
end
|
256
256
|
end
|
257
|
-
|
257
|
+
|
258
258
|
@scope[:nested_deep].pop
|
259
259
|
end
|
260
|
-
|
260
|
+
|
261
261
|
# Alias methods in order to handle i18n routes
|
262
262
|
def self.included(mod)
|
263
263
|
mod.send :alias_method_chain, :initialize, :i18n_routing
|
264
264
|
mod.send :alias_method_chain, :resource, :i18n_routing
|
265
265
|
mod.send :alias_method_chain, :resources, :i18n_routing
|
266
|
-
|
266
|
+
|
267
267
|
# Here we redefine some methods, in order to handle
|
268
268
|
# correct path_names translation on the fly
|
269
269
|
[:map_method, :member, :collection].each do |m|
|
@@ -272,7 +272,7 @@ module I18nRouting
|
|
272
272
|
if @localized_branch and @scope[:i18n_scope_level_resource] and @scope[:i18n_real_resource_name]
|
273
273
|
o = @scope[:scope_level_resource]
|
274
274
|
@scope[:scope_level_resource] = @scope[:i18n_scope_level_resource]
|
275
|
-
|
275
|
+
|
276
276
|
pname = @scope[:path_names] || {}
|
277
277
|
i = 1
|
278
278
|
while i < args.size and (String === args[i] or Symbol === args[i])
|
@@ -285,18 +285,18 @@ module I18nRouting
|
|
285
285
|
@scope[:scope_level_resource] = o
|
286
286
|
return
|
287
287
|
end
|
288
|
-
|
288
|
+
|
289
289
|
send(rfname, *args, &block)
|
290
290
|
end
|
291
|
-
|
291
|
+
|
292
292
|
mod.send :alias_method_chain, m, :i18n_routing
|
293
293
|
end
|
294
294
|
end
|
295
|
-
|
295
|
+
|
296
296
|
def resource_with_i18n_routing(*resources, &block)
|
297
297
|
create_globalized_resources(:resource, *resources, &block)
|
298
298
|
end
|
299
|
-
|
299
|
+
|
300
300
|
def resources_with_i18n_routing(*resources, &block)
|
301
301
|
create_globalized_resources(:resources, *resources, &block)
|
302
302
|
end
|
@@ -313,11 +313,12 @@ module I18nRouting
|
|
313
313
|
# try to get translated path :
|
314
314
|
I18n.locale = locale
|
315
315
|
ts = @path.gsub(/^\//, '')
|
316
|
+
append_format = ts =~ /\(\.:format\)/
|
316
317
|
ts.gsub!('(.:format)', '')
|
317
|
-
|
318
|
-
tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
|
318
|
+
|
319
|
+
tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
|
319
320
|
!ts.blank? && I18nRouting.translation_for(ts, :named_routes_path) || ts
|
320
|
-
|
321
|
+
|
321
322
|
localized_scope = I18nRouting.translation_for(@scope[:path].gsub(/\//, ''), :scopes) if @scope[:path]
|
322
323
|
path = localized_scope ? '/' << localized_scope : @scope[:path]
|
323
324
|
@localized_path = File.join((path || ''), tp).gsub(/\/$/, '')
|
@@ -327,6 +328,7 @@ module I18nRouting
|
|
327
328
|
#@options[:controller] ||= @options[:as]
|
328
329
|
@options[:as] = "#{I18nRouting.locale_escaped(locale)}_#{@options[:as]}"
|
329
330
|
@path = @localized_path
|
331
|
+
@path = "#{@path}(.:format)" if append_format
|
330
332
|
@options[:constraints] = @options[:constraints] ? @options[:constraints].dup : {}
|
331
333
|
@options[:constraints][:i18n_locale] = locale.to_s
|
332
334
|
@options[:anchor] = true
|
data/lib/i18n_routing_rails32.rb
CHANGED
@@ -7,7 +7,7 @@ module I18nRouting
|
|
7
7
|
module Mapper
|
8
8
|
|
9
9
|
private
|
10
|
-
|
10
|
+
|
11
11
|
# Just create a Mapper:Resource with given parameters
|
12
12
|
def resource_from_params(type, *resources)
|
13
13
|
res = resources.clone
|
@@ -17,7 +17,7 @@ module I18nRouting
|
|
17
17
|
|
18
18
|
type == :resource ? ActionDispatch::Routing::Mapper::SingletonResource.new(r, options.dup) : ActionDispatch::Routing::Mapper::Resource.new(r, options.dup)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# Localize a resources or a resource
|
22
22
|
def localized_resources(type = :resources, *resources, &block)
|
23
23
|
localizable_route = nil
|
@@ -42,7 +42,7 @@ module I18nRouting
|
|
42
42
|
opts = options.dup
|
43
43
|
opts[:path] = localized_path
|
44
44
|
opts[:controller] ||= r.to_s.pluralize
|
45
|
-
|
45
|
+
|
46
46
|
resource = resource_from_params(type, r, opts.dup)
|
47
47
|
|
48
48
|
res = ["#{I18nRouting.locale_escaped(locale)}_#{r}".to_sym, opts]
|
@@ -53,7 +53,7 @@ module I18nRouting
|
|
53
53
|
scope(:constraints => constraints, :path_names => I18nRouting.path_names(resource.name, @scope)) do
|
54
54
|
localized_branch(locale) do
|
55
55
|
send(type, *res) do
|
56
|
-
|
56
|
+
|
57
57
|
# In the resource(s) block, we need to keep and restore some context :
|
58
58
|
if block
|
59
59
|
old_name = @scope[:i18n_real_resource_name]
|
@@ -92,7 +92,7 @@ module I18nRouting
|
|
92
92
|
# If yes, localizable is a name, or a Mapper::Resource
|
93
93
|
# Can take a block, if so, save the current context, set the new
|
94
94
|
# Call the block, then restore the old context and return the block return
|
95
|
-
def set_localizable_route(localizable)
|
95
|
+
def set_localizable_route(localizable)
|
96
96
|
if block_given?
|
97
97
|
old = @set.named_routes.localizable
|
98
98
|
@set.named_routes.set_localizable_route(localizable)
|
@@ -103,11 +103,11 @@ module I18nRouting
|
|
103
103
|
@set.named_routes.set_localizable_route(localizable)
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def localizable_route
|
108
108
|
@set.named_routes.localizable
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
# Return the aproximate deep in scope level
|
112
112
|
def nested_deep
|
113
113
|
(@scope and Array === @scope[:nested_deep] and @scope[:scope_level]) ? @scope[:nested_deep].size : 0
|
@@ -155,7 +155,7 @@ module I18nRouting
|
|
155
155
|
I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml')]).flatten.uniq
|
156
156
|
@i18n_routing_path_set = true
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
old_value = @locales
|
160
160
|
@locales = locales
|
161
161
|
@i18n_verbose ||= opts.delete(:verbose)
|
@@ -163,7 +163,7 @@ module I18nRouting
|
|
163
163
|
ensure
|
164
164
|
@locales = old_value
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
# Create a branch for create routes in the specified locale
|
168
168
|
def localized_branch(locale)
|
169
169
|
set_localizable_route(nil) do
|
@@ -175,7 +175,7 @@ module I18nRouting
|
|
175
175
|
@localized_branch = old
|
176
176
|
end
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
# Set we do not want to localize next resource
|
180
180
|
def skip_localization
|
181
181
|
old = @skip_localization
|
@@ -226,7 +226,7 @@ module I18nRouting
|
|
226
226
|
|
227
227
|
super
|
228
228
|
end
|
229
|
-
|
229
|
+
|
230
230
|
def create_globalized_resources(type, *resources, &block)
|
231
231
|
#puts "#{' ' * nested_deep}Call #{type} : #{resources.inspect} (#{@locales.inspect}) (#{@localized_branch}) (#{@skip_localization})"
|
232
232
|
|
@@ -253,16 +253,16 @@ module I18nRouting
|
|
253
253
|
send("#{type}_without_i18n_routing".to_sym, *resources, &block)
|
254
254
|
end
|
255
255
|
end
|
256
|
-
|
256
|
+
|
257
257
|
@scope[:nested_deep].pop
|
258
258
|
end
|
259
|
-
|
259
|
+
|
260
260
|
# Alias methods in order to handle i18n routes
|
261
261
|
def self.included(mod)
|
262
262
|
mod.send :alias_method_chain, :initialize, :i18n_routing
|
263
263
|
mod.send :alias_method_chain, :resource, :i18n_routing
|
264
264
|
mod.send :alias_method_chain, :resources, :i18n_routing
|
265
|
-
|
265
|
+
|
266
266
|
# Here we redefine some methods, in order to handle
|
267
267
|
# correct path_names translation on the fly
|
268
268
|
[:map_method, :member, :collection].each do |m|
|
@@ -271,7 +271,7 @@ module I18nRouting
|
|
271
271
|
if @localized_branch and @scope[:i18n_scope_level_resource] and @scope[:i18n_real_resource_name]
|
272
272
|
o = @scope[:scope_level_resource]
|
273
273
|
@scope[:scope_level_resource] = @scope[:i18n_scope_level_resource]
|
274
|
-
|
274
|
+
|
275
275
|
pname = @scope[:path_names] || {}
|
276
276
|
i = 1
|
277
277
|
while i < args.size and (String === args[i] or Symbol === args[i])
|
@@ -284,18 +284,18 @@ module I18nRouting
|
|
284
284
|
@scope[:scope_level_resource] = o
|
285
285
|
return
|
286
286
|
end
|
287
|
-
|
287
|
+
|
288
288
|
send(rfname, *args, &block)
|
289
289
|
end
|
290
|
-
|
290
|
+
|
291
291
|
mod.send :alias_method_chain, m, :i18n_routing
|
292
292
|
end
|
293
293
|
end
|
294
|
-
|
294
|
+
|
295
295
|
def resource_with_i18n_routing(*resources, &block)
|
296
296
|
create_globalized_resources(:resource, *resources, &block)
|
297
297
|
end
|
298
|
-
|
298
|
+
|
299
299
|
def resources_with_i18n_routing(*resources, &block)
|
300
300
|
create_globalized_resources(:resources, *resources, &block)
|
301
301
|
end
|
@@ -312,11 +312,12 @@ module I18nRouting
|
|
312
312
|
# try to get translated path :
|
313
313
|
I18n.locale = locale
|
314
314
|
ts = @path.gsub(/^\//, '')
|
315
|
+
append_format = ts =~ /\(\.:format\)/
|
315
316
|
ts.gsub!('(.:format)', '')
|
316
|
-
|
317
|
-
tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
|
317
|
+
|
318
|
+
tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
|
318
319
|
!ts.blank? && I18nRouting.translation_for(ts, :named_routes_path) || ts
|
319
|
-
|
320
|
+
|
320
321
|
localized_scope = I18nRouting.translation_for(@scope[:path].gsub(/\//, ''), :scopes) if @scope[:path]
|
321
322
|
path = localized_scope ? '/' << localized_scope : @scope[:path]
|
322
323
|
@localized_path = File.join((path || ''), tp).gsub(/\/$/, '')
|
@@ -326,6 +327,7 @@ module I18nRouting
|
|
326
327
|
#@options[:controller] ||= @options[:as]
|
327
328
|
@options[:as] = "#{I18nRouting.locale_escaped(locale)}_#{@options[:as]}"
|
328
329
|
@path = @localized_path
|
330
|
+
@path = "#{@path}(.:format)" if append_format
|
329
331
|
@options[:constraints] = @options[:constraints] ? @options[:constraints].dup : {}
|
330
332
|
@options[:constraints][:i18n_locale] = locale.to_s
|
331
333
|
@options[:anchor] = true
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe :localized_routes do
|
4
4
|
|
5
5
|
$r = nil # Global routes in order to speed up testing
|
6
|
-
|
6
|
+
|
7
7
|
before(:all) do
|
8
8
|
|
9
9
|
if !$r
|
@@ -18,23 +18,23 @@ describe :localized_routes do
|
|
18
18
|
map.about 'about', :controller => 'about', :action => :show
|
19
19
|
map.welcome 'welcome/to/our/page', :controller => :welcome, :action => :index
|
20
20
|
map.empty 'empty', :controller => 'empty', :action => :show
|
21
|
-
|
21
|
+
|
22
22
|
map.resources :users, :member => {:level => :get, :one => :get, :two => :get}, :collection => {:groups => :get}
|
23
23
|
map.resource :contact
|
24
|
-
|
24
|
+
|
25
25
|
map.resources :authors do |m|
|
26
26
|
m.resources :books
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
map.resources :empty_resources
|
30
|
-
|
30
|
+
|
31
31
|
map.resource :foo do |m|
|
32
32
|
m.resources :bars
|
33
33
|
m.resource :foofoo do |mm|
|
34
34
|
mm.resources :bars
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
map.resources :universes do |m|
|
39
39
|
m.resources :galaxies do |mm|
|
40
40
|
mm.resources :planets do |mmm|
|
@@ -42,20 +42,20 @@ describe :localized_routes do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
map.with_options :path_prefix => ':locale' do |l|
|
47
47
|
l.localized_root '/', :controller => "about", :action => "show"
|
48
48
|
l.about_with_locale 'about', :controller => "about", :action => "show"
|
49
49
|
l.about_with_locale_with_sep 'about', :controller => "about", :action => "show"
|
50
50
|
l.resources :empty__resources
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
map.resources :drones, :path_prefix => 'doubledrones/unimatrix/zero'
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
$r = ActionController::Routing::Routes
|
58
|
-
|
58
|
+
|
59
59
|
class UrlTester
|
60
60
|
include ActionController::UrlWriter
|
61
61
|
end
|
@@ -127,7 +127,7 @@ describe :localized_routes do
|
|
127
127
|
|
128
128
|
end
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
class UrlTester; end
|
132
132
|
UrlTester.send :include, $r.url_helpers
|
133
133
|
|
@@ -201,11 +201,11 @@ describe :localized_routes do
|
|
201
201
|
routes.send(:universe_galaxies_path, 1).should == "/universes/1/galaxies"
|
202
202
|
routes.send(:universe_galaxy_planets_path, 1, 1).should == "/universes/1/galaxies/1/planets"
|
203
203
|
end
|
204
|
-
|
204
|
+
|
205
205
|
it "single resource should have by default the pluralized controller" do
|
206
206
|
nested_routes[:foo].defaults[:controller].should == 'foos'
|
207
207
|
end
|
208
|
-
|
208
|
+
|
209
209
|
it "scope with parameters should be respected" do
|
210
210
|
routes.send(:localized_root_path, I18n.locale).should == "/#{I18n.locale}"
|
211
211
|
end
|
@@ -222,7 +222,7 @@ describe :localized_routes do
|
|
222
222
|
before do
|
223
223
|
I18n.locale = :fr
|
224
224
|
end
|
225
|
-
|
225
|
+
|
226
226
|
it "scope with parameters should be respected" do
|
227
227
|
routes.send(:localized_root_path, I18n.locale).should == "/#{I18n.locale}"
|
228
228
|
end
|
@@ -243,14 +243,14 @@ describe :localized_routes do
|
|
243
243
|
|
244
244
|
it "named_route generated route from actual route name" do
|
245
245
|
I18n.locale = :en
|
246
|
-
routes.send(:welcome_path).should == "/#{I18n.t :welcome, :scope => :named_routes}"
|
246
|
+
routes.send(:welcome_path).should == "/#{I18n.t :welcome, :scope => :named_routes}"
|
247
247
|
I18n.locale = :fr
|
248
248
|
end
|
249
|
-
|
249
|
+
|
250
250
|
it "named_route generates route from route path when route name not available" do
|
251
251
|
routes.send(:welcome_path).should == "/#{I18n.t 'welcome/to/our/page', :scope => :named_routes_path}"
|
252
|
-
end
|
253
|
-
|
252
|
+
end
|
253
|
+
|
254
254
|
it "doesn't translate empty route" do
|
255
255
|
routes.send(:empty_path).should_not == "/#{I18n.t 'empty', :scope => :named_routes_path}"
|
256
256
|
routes.send(:empty_path).should == "/empty"
|
@@ -289,6 +289,15 @@ describe :localized_routes do
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
|
+
it "url_for generates routes using localized values even with format specified" do
|
293
|
+
url_for(:controller => :users, :format => "html").should == "/#{I18n.t :as, :scope => :'routes.users'}.html"
|
294
|
+
url_for(:controller => :about, :action => :show, :format => "html").should == "/#{I18n.t :about, :scope => :named_routes_path}.html"
|
295
|
+
if rails3?
|
296
|
+
url_for(:controller => :about2, :action => :show, :format => "html").should == "/#{I18n.t :about2, :scope => :named_routes_path}.html"
|
297
|
+
url_for(:controller => :pages, :action => :home, :format => "html").should == "/#{I18n.t :home, :scope => :named_routes_path}.html"
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
292
301
|
if !rails3?
|
293
302
|
it "url_for generates routes for drones with path prefix" do
|
294
303
|
url_for(:controller => :drones).should == "#{I18n.t :path_prefix, :scope => :'routes.drones'}/#{I18n.t :as, :scope => :'routes.drones'}"
|
@@ -307,24 +316,24 @@ describe :localized_routes do
|
|
307
316
|
end
|
308
317
|
|
309
318
|
context "with path_names" do
|
310
|
-
|
319
|
+
|
311
320
|
it "default translated path names" do
|
312
321
|
routes.send(:new_universe_path).should == "/#{I18n.t :universes, :scope => :resources}/#{I18n.t :new, :scope => :path_names}"
|
313
322
|
routes.send(:edit_universe_path, 42).should == "/#{I18n.t :universes, :scope => :resources}/42/#{I18n.t :edit, :scope => :path_names}"
|
314
323
|
end
|
315
|
-
|
324
|
+
|
316
325
|
it "custom translated path names" do
|
317
326
|
routes.send(:new_user_path).should == "/#{I18n.t :users, :scope => :resources}/#{I18n.t :new, :scope => :'routes.users.path_names'}"
|
318
327
|
routes.send(:edit_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/#{I18n.t :edit, :scope => :'routes.users.path_names'}"
|
319
328
|
end
|
320
|
-
|
329
|
+
|
321
330
|
end
|
322
|
-
|
331
|
+
|
323
332
|
context "with member and collection" do
|
324
333
|
|
325
334
|
it "custom member" do
|
326
335
|
I18n.locale = :en
|
327
|
-
routes.send(:level_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/level"
|
336
|
+
routes.send(:level_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/level"
|
328
337
|
I18n.locale = :fr
|
329
338
|
routes.send(:level_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/#{I18n.t :level, :scope => :'routes.users.path_names'}"
|
330
339
|
routes.send(:one_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/#{I18n.t :one, :scope => :'routes.users.path_names'}"
|
@@ -333,7 +342,7 @@ describe :localized_routes do
|
|
333
342
|
|
334
343
|
it "custom collection" do
|
335
344
|
I18n.locale = :en
|
336
|
-
routes.send(:groups_users_path).should == "/#{I18n.t :users, :scope => :resources}/groups"
|
345
|
+
routes.send(:groups_users_path).should == "/#{I18n.t :users, :scope => :resources}/groups"
|
337
346
|
I18n.locale = :fr
|
338
347
|
routes.send(:groups_users_path).should == "/#{I18n.t :users, :scope => :resources}/#{I18n.t :groups, :scope => :'routes.users.path_names'}"
|
339
348
|
end
|
@@ -396,7 +405,7 @@ describe :localized_routes do
|
|
396
405
|
|
397
406
|
it "nested resources do not deep translate with multi helpers" do
|
398
407
|
nested_routes.keys.should_not include(:fr_author_books) # Do not want fr_author_books
|
399
|
-
end
|
408
|
+
end
|
400
409
|
|
401
410
|
end
|
402
411
|
|
@@ -420,7 +429,7 @@ describe :localized_routes do
|
|
420
429
|
#routes.send(:weshs_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}"
|
421
430
|
#routes.send(:wesh_in_wesh_path).should == "/#{I18n.t :german, :scope => :scopes}/#{I18n.t :weshs, :scope => :resources}/#{I18n.t :in_weshs, :scope => :resources}"
|
422
431
|
end
|
423
|
-
|
432
|
+
|
424
433
|
end
|
425
434
|
end
|
426
435
|
|
@@ -433,11 +442,11 @@ describe :localized_routes do
|
|
433
442
|
it 'users resources' do
|
434
443
|
routes.send(:users_path).should == "/#{I18n.t :users, :scope => :'resources'}"
|
435
444
|
end
|
436
|
-
|
445
|
+
|
437
446
|
it "routes for the singleton resource alone should be translated correctly" do
|
438
447
|
routes.send(:foo_path).should == "/#{I18n.t :foo, :scope => :resource}"
|
439
448
|
end
|
440
|
-
|
449
|
+
|
441
450
|
it "named_route generates route using localized values" do
|
442
451
|
routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
|
443
452
|
if rails3?
|
@@ -445,11 +454,11 @@ describe :localized_routes do
|
|
445
454
|
routes.send(:main_path).should == "/#{I18n.t :home, :scope => :named_routes_path}"
|
446
455
|
end
|
447
456
|
end
|
448
|
-
|
457
|
+
|
449
458
|
it "custom translated path names" do
|
450
459
|
routes.send(:new_user_path).should == "/#{I18n.t :users, :scope => :resources}/#{I18n.t :new, :scope => :'path_names'}"
|
451
460
|
end
|
452
|
-
|
461
|
+
|
453
462
|
end
|
454
463
|
|
455
464
|
# context "just output" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_routing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>'
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 0.3.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>'
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.5
|
25
30
|
description: I18n_routing is a plugin for Ruby on Rails that lets you easily translate
|
26
31
|
your routes trough the I18n api included in Rails since version 2.2
|
27
32
|
email: guillaume.luccisano@gmail.com
|
@@ -61,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
66
|
version: '0'
|
62
67
|
segments:
|
63
68
|
- 0
|
64
|
-
hash:
|
69
|
+
hash: -581614191
|
65
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
71
|
none: false
|
67
72
|
requirements:
|
@@ -70,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
75
|
version: 1.3.4
|
71
76
|
requirements: []
|
72
77
|
rubyforge_project: i18n_routing
|
73
|
-
rubygems_version: 1.8.
|
78
|
+
rubygems_version: 1.8.24
|
74
79
|
signing_key:
|
75
80
|
specification_version: 3
|
76
81
|
summary: I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with
|