i18n_routing 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -27,5 +27,6 @@ Furthermore, if the i18n gem is present on your system, Rails will load it and s
27
27
  * mixr (Reiner Dieterich)
28
28
  * fwalch
29
29
  * doubledrones: h13ronim (Marcin Michałowski)
30
+ * rudionrails (Rudolf Schmidt)
30
31
 
31
32
  Copyright (c) 2010 Guillaume Luccisano - g-mai|: guillaume.luccisano, released under the MIT license
@@ -99,7 +99,8 @@ module ActionController
99
99
  @locales.each do |l|
100
100
  I18n.locale = l
101
101
  nt = "#{l}_#{name}"
102
- if nt != name and (t = I18nRouting.translation_for(path, :named_routes_path))
102
+ t = I18nRouting.translation_for(name, :named_routes) || I18nRouting.translation_for(path, :named_routes_path)
103
+ if nt != name and t
103
104
  gl_add_named_route(nt, t, options.merge(:glang => l))
104
105
  puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', name, l, t]) if @i18n_verbose
105
106
  end
@@ -294,7 +294,12 @@ module I18nRouting
294
294
  I18n.locale = locale
295
295
  ts = @path.gsub(/^\//, '')
296
296
  ts.gsub!('(.:format)', '')
297
- @localized_path = (@scope[:path] || '/') + (!ts.blank? ? (I18nRouting.translation_for(ts, :named_routes_path) || ts) : '')
297
+
298
+ tp = @options[:as] && I18nRouting.translation_for(@options[:as], :named_routes) ||
299
+ !ts.blank? && I18nRouting.translation_for(ts, :named_routes_path) || ''
300
+
301
+
302
+ @localized_path = (@scope[:path] || '/') + tp
298
303
 
299
304
  # If a translated path exists, set localized infos
300
305
  if @localized_path and @localized_path != @path
@@ -16,6 +16,7 @@ describe :localized_routes do
16
16
 
17
17
  map.localized(I18n.available_locales, :verbose => false) do
18
18
  map.about 'about', :controller => 'about', :action => :show
19
+ map.welcome 'welcome/to/our/page', :controller => :welcome, :action => :index
19
20
 
20
21
  map.resources :users, :member => {:level => :get, :one => :get, :two => :get}, :collection => {:groups => :get}
21
22
  map.resource :contact
@@ -60,6 +61,7 @@ describe :localized_routes do
60
61
 
61
62
  localized(I18n.available_locales, :verbose => false) do
62
63
  match 'about' => "about#show", :as => :about
64
+ match 'welcome/to/our/page' => "welcome#index", :as => :welcome
63
65
 
64
66
  scope '/:locale', :constraints => { :locale => /[a-z]{2}/ } do
65
67
  match '/' => "about#show", :as => :localized_root
@@ -137,6 +139,7 @@ describe :localized_routes do
137
139
 
138
140
  it "named_route uses default values" do
139
141
  routes.send(:about_path).should == "/about"
142
+ routes.send(:welcome_path).should == '/welcome/to/our/page'
140
143
  end
141
144
 
142
145
  it "resource generates routes using default values" do
@@ -180,6 +183,16 @@ describe :localized_routes do
180
183
  it "named_route generates route using localized values" do
181
184
  routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
182
185
  end
186
+
187
+ it "named_route generated route from actual route name" do
188
+ I18n.locale = :en
189
+ routes.send(:welcome_path).should == "/#{I18n.t :welcome, :scope => :named_routes}"
190
+ I18n.locale = :fr
191
+ end
192
+
193
+ it "named_route generates route from route path when route name not available" do
194
+ routes.send(:welcome_path).should == "/#{I18n.t 'welcome/to/our/page', :scope => :named_routes_path}"
195
+ end
183
196
 
184
197
  it "named_route generates route using localized values and I18n.locale as a string" do
185
198
  o = I18n.locale
data/spec/locales/en.yml CHANGED
@@ -11,3 +11,5 @@ en:
11
11
  contact: 'contact-us'
12
12
  named_routes_path:
13
13
  about: 'about-our-company'
14
+ named_routes:
15
+ welcome: 'welcome-to-our-page'
data/spec/locales/fr.yml CHANGED
@@ -27,6 +27,7 @@ fr:
27
27
  contact: 'contactez-nous'
28
28
  named_routes_path:
29
29
  about: 'a-propos'
30
+ 'welcome/to/our/page': 'bienvenue/sur/notre/site' # no idea about french translation ;-) --R
30
31
  path_names:
31
32
  new: 'nouveau'
32
33
  edit: 'edition'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 2
9
- version: 0.4.2
8
+ - 3
9
+ version: 0.4.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Guillaume Luccisano
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-20 00:00:00 +02:00
17
+ date: 2010-10-11 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: i18n
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">"
26
27
  - !ruby/object:Gem::Version
@@ -63,6 +64,7 @@ rdoc_options: []
63
64
  require_paths:
64
65
  - lib
65
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
66
68
  requirements:
67
69
  - - ">="
68
70
  - !ruby/object:Gem::Version
@@ -70,6 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
72
  - 0
71
73
  version: "0"
72
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
73
76
  requirements:
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
@@ -81,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
84
  requirements: []
82
85
 
83
86
  rubyforge_project: i18n_routing
84
- rubygems_version: 1.3.6
87
+ rubygems_version: 1.3.7
85
88
  signing_key:
86
89
  specification_version: 3
87
90
  summary: I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !