i18n_routing 0.3.7 → 0.3.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/CHANGELOG.rdoc +4 -0
- data/README.rdoc +4 -2
- data/lib/i18n_routing_rails2.rb +2 -0
- data/lib/i18n_routing_rails3.rb +11 -7
- data/spec/i18n_routing/i18n_spec.rb +8 -0
- data/spec/locales/fr.yml +3 -0
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -6,12 +6,13 @@ All necessary informations are available on the wiki: http://wiki.github.com/kwi
|
|
6
6
|
|
7
7
|
For any question, use the i18_routing google group: http://groups.google.com/group/i18n-routing
|
8
8
|
|
9
|
-
Works with Rails 2.3 and
|
9
|
+
Works with Rails 2.3 and Rails 3.0 ! (nested resources currently do not work on Rails3, will be fixed when Rails3 is released)
|
10
|
+
=> Rails3 beta and RC versions are no longer supported !
|
10
11
|
|
11
12
|
== TODO for next releases (written the 9th of June)
|
12
13
|
|
13
14
|
* Handle multiple translations for same resources name (Example: nested and not nested resources)
|
14
|
-
* Handle namespace translation
|
15
|
+
* Handle namespace translation (and path_prefix on Rails3)
|
15
16
|
|
16
17
|
== I18n gem version warning
|
17
18
|
|
@@ -25,5 +26,6 @@ Furthermore, if the i18n gem is present on your system, Rails will load it and s
|
|
25
26
|
* bigtiger (Jim Remsik)
|
26
27
|
* mixr (Reiner Dieterich)
|
27
28
|
* fwalch
|
29
|
+
* doubledrones: h13ronim (Marcin Michałowski)
|
28
30
|
|
29
31
|
Copyright (c) 2010 Guillaume Luccisano - g-mai|: guillaume.luccisano, released under the MIT license
|
data/lib/i18n_routing_rails2.rb
CHANGED
@@ -176,6 +176,8 @@ module ActionController
|
|
176
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
|
+
path_prefix_t = I18n.t(:path_prefix, :scope => :"routes.#{name}", :default => "NoPathPrefixTranslation")
|
180
|
+
opts[:path_prefix] = path_prefix_t unless path_prefix_t == "NoPathPrefixTranslation"
|
179
181
|
|
180
182
|
localized([l]) do
|
181
183
|
switch_no_named_localization(true) do
|
data/lib/i18n_routing_rails3.rb
CHANGED
@@ -182,15 +182,18 @@ module I18nRouting
|
|
182
182
|
|
183
183
|
def match(*args)
|
184
184
|
# Localize simple match only if there is no resource scope.
|
185
|
-
if args.size == 1 and @locales and !parent_resource and args.first[:as]
|
185
|
+
if args.size == 1 and @locales and !parent_resource and args.last.is_a?(Hash) and args.first[:as]
|
186
|
+
options = Marshal.load(Marshal.dump(args.first))
|
187
|
+
path, to = options.find { |name, value| name.is_a?(String) }
|
188
|
+
options.merge!(:to => to).delete(path)
|
186
189
|
@locales.each do |locale|
|
187
|
-
mapping = LocalizedMapping.new(locale, @set, @scope,
|
190
|
+
mapping = LocalizedMapping.new(locale, @set, @scope, path, options) # Dump is dirty but how to make deep cloning easily ? :/
|
188
191
|
if mapping.localizable?
|
189
192
|
puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', args.first[:as], locale, mapping.path]) if @i18n_verbose
|
190
193
|
@set.add_route(*mapping.to_route)
|
191
194
|
end
|
192
195
|
end
|
193
|
-
|
196
|
+
|
194
197
|
# Now, create the real match :
|
195
198
|
return set_localizable_route(args.first[:as]) do
|
196
199
|
super
|
@@ -274,12 +277,13 @@ module I18nRouting
|
|
274
277
|
|
275
278
|
attr_reader :path
|
276
279
|
|
277
|
-
def initialize(locale, set, scope,
|
278
|
-
super(set, scope,
|
280
|
+
def initialize(locale, set, scope, path, options)
|
281
|
+
super(set, scope, path.clone, options ? options.clone : nil)
|
279
282
|
|
280
283
|
# try to get translated path :
|
281
284
|
I18n.locale = locale
|
282
285
|
ts = @path.gsub(/^\//, '')
|
286
|
+
ts.gsub!('(.:format)', '')
|
283
287
|
@localized_path = '/' + (I18nRouting.translation_for(ts, :named_routes_path) || ts)
|
284
288
|
|
285
289
|
# If a translated path exists, set localized infos
|
@@ -373,5 +377,5 @@ module I18nRouting
|
|
373
377
|
end
|
374
378
|
end
|
375
379
|
|
376
|
-
ActionDispatch::Routing::Mapper.send
|
377
|
-
Rack::Mount::Route.send
|
380
|
+
ActionDispatch::Routing::Mapper.send :include, I18nRouting::Mapper
|
381
|
+
Rack::Mount::Route.send :include, I18nRouting::RackMountRoute
|
@@ -38,6 +38,8 @@ describe :localized_routes do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
map.resources :drones, :path_prefix => 'doubledrones/unimatrix/zero'
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -189,6 +191,12 @@ describe :localized_routes do
|
|
189
191
|
url_for(:controller => :about, :action => :show).should == "/#{I18n.t :about, :scope => :named_routes_path}"
|
190
192
|
end
|
191
193
|
|
194
|
+
if !rails3?
|
195
|
+
it "url_for generates routes for drones with path prefix" do
|
196
|
+
url_for(:controller => :drones).should == "#{I18n.t :path_prefix, :scope => :'routes.drones'}/#{I18n.t :as, :scope => :'routes.drones'}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
192
200
|
it "nested resources generate routes using localized values" do
|
193
201
|
routes.send(:author_books_path, 1).should == "/#{I18n.t :authors, :scope => :resources}/1/#{I18n.t :books, :scope => :resources}"
|
194
202
|
end
|
data/spec/locales/fr.yml
CHANGED
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
|
+
- 8
|
9
|
+
version: 0.3.8
|
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-08-
|
17
|
+
date: 2010-08-30 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|