i18n_routing 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/lib/i18n_routing_rails2.rb +1 -1
- data/lib/i18n_routing_rails3.rb +3 -3
- data/spec/i18n_routing/i18n_spec.rb +12 -5
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/lib/i18n_routing_rails2.rb
CHANGED
@@ -173,7 +173,7 @@ module ActionController
|
|
173
173
|
nt = "#{l}_#{name}"
|
174
174
|
opts[:as] = t
|
175
175
|
opts[:glang] = l
|
176
|
-
opts[:controller] ||= name
|
176
|
+
opts[:controller] ||= name.to_s.pluralize
|
177
177
|
opts[:real_path] = opts[:singular] || name
|
178
178
|
opts[:path_names] = I18nRouting.path_names(name, options)
|
179
179
|
|
data/lib/i18n_routing_rails3.rb
CHANGED
@@ -40,7 +40,7 @@ module I18nRouting
|
|
40
40
|
puts("[I18n] > localize %-10s: %40s (%s) => /%s" % [type, resource.name, locale, localized_path]) if @i18n_verbose
|
41
41
|
opts = options.dup
|
42
42
|
opts[:path] = localized_path.to_sym
|
43
|
-
opts[:controller] ||= r
|
43
|
+
opts[:controller] ||= r.to_s.pluralize
|
44
44
|
|
45
45
|
res = ["#{locale}_#{r}".to_sym, opts]
|
46
46
|
|
@@ -59,10 +59,10 @@ module I18nRouting
|
|
59
59
|
@scope[:i18n_real_resource_name] = resource.name
|
60
60
|
@scope[:i18n_scope_level_resource] = old
|
61
61
|
@scope[:scope_level_resource] = resource
|
62
|
-
|
62
|
+
|
63
63
|
if type == :resource and @scope[:name_prefix]
|
64
64
|
# Need to fake name_prefix for singleton resource
|
65
|
-
@scope[:name_prefix].gsub
|
65
|
+
@scope[:name_prefix] = @scope[:name_prefix].gsub(Regexp.new("#{old.name}$"), resource.name)
|
66
66
|
end
|
67
67
|
|
68
68
|
block.call if block
|
@@ -152,6 +152,10 @@ describe :localized_routes do
|
|
152
152
|
routes.send(:universe_galaxies_path, 1).should == "/universes/1/galaxies"
|
153
153
|
routes.send(:universe_galaxy_planets_path, 1, 1).should == "/universes/1/galaxies/1/planets"
|
154
154
|
end
|
155
|
+
|
156
|
+
it "single resource should have by default the pluralized controller" do
|
157
|
+
nested_routes[:foo].defaults[:controller].should == 'foos'
|
158
|
+
end
|
155
159
|
|
156
160
|
end
|
157
161
|
|
@@ -165,7 +169,7 @@ describe :localized_routes do
|
|
165
169
|
routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
|
166
170
|
end
|
167
171
|
|
168
|
-
it "resource generates routes using localized
|
172
|
+
it "resource generates routes using localized values" do
|
169
173
|
routes.send(:contact_path).should == "/#{I18n.t :contact, :scope => :resource}"
|
170
174
|
end
|
171
175
|
|
@@ -239,20 +243,23 @@ describe :localized_routes do
|
|
239
243
|
|
240
244
|
context "when nested inside a singleton resource" do
|
241
245
|
|
242
|
-
it "named routes should have
|
246
|
+
it "named routes should have locale placed at correct position" do
|
243
247
|
nested_routes[:fr_foo_fr_bars].should be_nil
|
244
248
|
nested_routes[:foo_fr_bars].should_not be_nil
|
245
249
|
end
|
246
250
|
|
247
|
-
it "routes should be translated
|
251
|
+
it "routes for the singleton resource alone should be translated correctly" do
|
252
|
+
routes.send(:foo_path).should == "/#{I18n.t :foo, :scope => :resource}"
|
253
|
+
end
|
254
|
+
|
255
|
+
it "routes should be translated correctly" do
|
248
256
|
routes.send(:foo_bars_path).should == "/#{I18n.t :foo, :scope => :resource}/#{I18n.t :bars, :scope => :resources}"
|
249
257
|
end
|
250
258
|
|
251
|
-
it "routes should be translated
|
259
|
+
it "routes should be translated correctly also with deep nested singleton resource" do
|
252
260
|
routes.send(:foo_foofoo_bars_path).should == "/#{I18n.t :foo, :scope => :resource}/#{I18n.t :foofoo, :scope => :resource}/#{I18n.t :bars, :scope => :resources}"
|
253
261
|
end
|
254
262
|
|
255
|
-
|
256
263
|
end
|
257
264
|
|
258
265
|
context "when deeply nested" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Guillaume Luccisano
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-03 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|