i18n_routing 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.8 (August 30, 2010)
2
+
3
+ * Support the first Rails3 official release (but nested resources is still broken)
4
+
1
5
  0.3.7 (August 26, 2010)
2
6
 
3
7
  * Support Rails3 RC2 thanks to fwalch / Rails3 final will probably require a new version of i18n_routing
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 Rails3 RC2 ! (nested resources currently do not work on Rails3 RC2, will be fixed when Rails3 is released)
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
@@ -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
@@ -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, Marshal.load(Marshal.dump(args))) # Dump is dirty but how to make deep cloning easily ? :/
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, args)
278
- super(set, scope, args.clone)
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 :include, I18nRouting::Mapper
377
- Rack::Mount::Route.send :include, I18nRouting::RackMountRoute
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
@@ -7,6 +7,9 @@ fr:
7
7
  groups: 'groupe'
8
8
  new: 'nouvel_utilisateur'
9
9
  edit: 'edition_utilisateur'
10
+ drones:
11
+ as: senord
12
+ path_prefix: '/senordelbuod/xirtaminu/orez'
10
13
  resources:
11
14
  users: utilisateurs
12
15
  authors: 'auteurs'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 7
9
- version: 0.3.7
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-26 00:00:00 +02:00
17
+ date: 2010-08-30 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency