i18n_routing 0.4.5 → 0.4.6
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/Rakefile +8 -8
- data/lib/i18n_routing_rails2.rb +2 -2
- data/lib/i18n_routing_rails3.rb +3 -3
- data/spec/i18n_routing/i18n_spec.rb +14 -2
- data/spec/locales/fr.yml +2 -0
- data/spec/spec_helper.rb +1 -1
- metadata +4 -18
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require '
|
4
|
-
|
5
|
-
spec_files = Rake::FileList["spec/**/*_spec.rb"]
|
3
|
+
require 'rspec/core/rake_task'
|
6
4
|
|
5
|
+
# Now using RSpec 2
|
7
6
|
|
8
7
|
desc "Run specs for current Rails version"
|
9
|
-
|
10
|
-
t.
|
11
|
-
t.
|
12
|
-
|
13
|
-
}
|
8
|
+
RSpec::Core::RakeTask.new do |t|
|
9
|
+
t.pattern = "spec/**/*_spec.rb"
|
10
|
+
t.verbose = true
|
11
|
+
# t.ruby_opts = lambda {
|
12
|
+
# @rails_spec_version ? ["-c --format specdoc -- rails_spec_version=#{@rails_spec_version}"] : ["-c --format specdoc"]
|
13
|
+
# }
|
14
14
|
end
|
15
15
|
|
16
16
|
task :default => :spec
|
data/lib/i18n_routing_rails2.rb
CHANGED
@@ -100,7 +100,7 @@ module ActionController
|
|
100
100
|
I18n.locale = l
|
101
101
|
nt = "#{I18nRouting.locale_escaped(l)}_#{name}"
|
102
102
|
t = I18nRouting.translation_for(name, :named_routes) || I18nRouting.translation_for(path, :named_routes_path)
|
103
|
-
if nt != name and t
|
103
|
+
if nt != name and !t.blank?
|
104
104
|
gl_add_named_route(nt, t, options.merge(:glang => l))
|
105
105
|
puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', name, l, t]) if @i18n_verbose
|
106
106
|
end
|
@@ -170,7 +170,7 @@ module ActionController
|
|
170
170
|
locales.each do |l|
|
171
171
|
I18n.locale = l
|
172
172
|
nt = "#{I18nRouting.locale_escaped(l)}_#{name}"
|
173
|
-
if nt != name and (t = I18nRouting.translation_for(name, namespace))
|
173
|
+
if nt != name and !(t = I18nRouting.translation_for(name, namespace)).blank?
|
174
174
|
opts[:as] = t
|
175
175
|
opts[:glang] = l
|
176
176
|
opts[:controller] ||= name.to_s.pluralize
|
data/lib/i18n_routing_rails3.rb
CHANGED
@@ -185,11 +185,11 @@ module I18nRouting
|
|
185
185
|
def match(*args)
|
186
186
|
# Localize simple match only if there is no resource scope.
|
187
187
|
if args.size == 1 and @locales and !parent_resource and args.last.is_a?(Hash) and args.first[:as]
|
188
|
-
options = Marshal.load(Marshal.dump(args.first))
|
188
|
+
options = Marshal.load(Marshal.dump(args.first)) # Dump is dirty but how to make deep cloning easily ? :/
|
189
189
|
path, to = options.find { |name, value| name.is_a?(String) }
|
190
190
|
options.merge!(:to => to).delete(path)
|
191
191
|
@locales.each do |locale|
|
192
|
-
mapping = LocalizedMapping.new(locale, @set, @scope, path, options)
|
192
|
+
mapping = LocalizedMapping.new(locale, @set, @scope, path, options)
|
193
193
|
if mapping.localizable?
|
194
194
|
puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', args.first[:as], locale, mapping.path]) if @i18n_verbose
|
195
195
|
@set.add_route(*mapping.to_route)
|
@@ -301,7 +301,7 @@ module I18nRouting
|
|
301
301
|
@localized_path = File.join((@scope[:path] || ''), tp).gsub(/\/$/, '')
|
302
302
|
|
303
303
|
# If a translated path exists, set localized infos
|
304
|
-
if
|
304
|
+
if !@localized_path.blank? and @localized_path != @path
|
305
305
|
#@options[:controller] ||= @options[:as]
|
306
306
|
@options[:as] = "#{I18nRouting.locale_escaped(locale)}_#{@options[:as]}"
|
307
307
|
@path = @localized_path
|
@@ -17,6 +17,7 @@ describe :localized_routes do
|
|
17
17
|
map.localized(I18n.available_locales, :verbose => false) do
|
18
18
|
map.about 'about', :controller => 'about', :action => :show
|
19
19
|
map.welcome 'welcome/to/our/page', :controller => :welcome, :action => :index
|
20
|
+
map.empty 'empty', :controller => 'empty', :action => :show
|
20
21
|
|
21
22
|
map.resources :users, :member => {:level => :get, :one => :get, :two => :get}, :collection => {:groups => :get}
|
22
23
|
map.resource :contact
|
@@ -25,6 +26,8 @@ describe :localized_routes do
|
|
25
26
|
m.resources :books
|
26
27
|
end
|
27
28
|
|
29
|
+
map.resources :empty_resources
|
30
|
+
|
28
31
|
map.resource :foo do |m|
|
29
32
|
m.resources :bars
|
30
33
|
m.resource :foofoo do |mm|
|
@@ -62,13 +65,15 @@ describe :localized_routes do
|
|
62
65
|
$r.draw do
|
63
66
|
match 'not_about' => "not_about#show", :as => :not_about
|
64
67
|
resources :not_users
|
68
|
+
resources :empty_resources
|
65
69
|
resource :not_contact
|
66
70
|
|
67
|
-
localized(I18n.available_locales, :verbose =>
|
71
|
+
localized(I18n.available_locales, :verbose => true) do
|
68
72
|
match 'about' => "about#show", :as => :about
|
69
73
|
match 'welcome/to/our/page' => "welcome#index", :as => :welcome
|
74
|
+
match 'empty' => 'empty#show', :as => :empty
|
70
75
|
|
71
|
-
scope '/:locale'
|
76
|
+
scope '/:locale' do #, :constraints => { :locale => /[a-z]{2}/ } do ### Commented => this constraint fail on rails 3.0.4 ??
|
72
77
|
match '/' => "about#show", :as => :localized_root
|
73
78
|
match 'about' => "about#show", :as => :about_with_locale
|
74
79
|
match '/about' => "about#show", :as => :about_with_locale_with_sep
|
@@ -214,6 +219,13 @@ describe :localized_routes do
|
|
214
219
|
it "named_route generates route from route path when route name not available" do
|
215
220
|
routes.send(:welcome_path).should == "/#{I18n.t 'welcome/to/our/page', :scope => :named_routes_path}"
|
216
221
|
end
|
222
|
+
|
223
|
+
it "doesn't translate empty route" do
|
224
|
+
routes.send(:empty_path).should_not == "/#{I18n.t 'empty', :scope => :named_routes_path}"
|
225
|
+
routes.send(:empty_path).should == "/empty"
|
226
|
+
routes.send(:empty_resources_path).should_not == "/#{I18n.t 'empty', :scope => :named_routes_path}"
|
227
|
+
routes.send(:empty_resources_path).should == "/empty_resources"
|
228
|
+
end
|
217
229
|
|
218
230
|
it "named_route generates route using localized values and I18n.locale as a string" do
|
219
231
|
o = I18n.locale
|
data/spec/locales/fr.yml
CHANGED
@@ -21,6 +21,7 @@ fr:
|
|
21
21
|
universes: 'univers'
|
22
22
|
countries: 'pays'
|
23
23
|
bars: bars_fr
|
24
|
+
empty_resources: ''
|
24
25
|
resource:
|
25
26
|
foo: foo_fr
|
26
27
|
foofoo: froufrou
|
@@ -28,6 +29,7 @@ fr:
|
|
28
29
|
named_routes_path:
|
29
30
|
about: 'a-propos'
|
30
31
|
'welcome/to/our/page': 'bienvenue/sur/notre/site' # no idea about french translation ;-) --R
|
32
|
+
empty: ''
|
31
33
|
path_names:
|
32
34
|
new: 'nouveau'
|
33
35
|
edit: 'edition'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_routing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 5
|
9
|
-
version: 0.4.5
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.6
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Guillaume Luccisano
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-02-14 00:00:00 -08:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">"
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 3
|
31
|
-
- 5
|
32
24
|
version: 0.3.5
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -69,23 +61,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
61
|
requirements:
|
70
62
|
- - ">="
|
71
63
|
- !ruby/object:Gem::Version
|
72
|
-
segments:
|
73
|
-
- 0
|
74
64
|
version: "0"
|
75
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
66
|
none: false
|
77
67
|
requirements:
|
78
68
|
- - ">="
|
79
69
|
- !ruby/object:Gem::Version
|
80
|
-
segments:
|
81
|
-
- 1
|
82
|
-
- 3
|
83
|
-
- 4
|
84
70
|
version: 1.3.4
|
85
71
|
requirements: []
|
86
72
|
|
87
73
|
rubyforge_project: i18n_routing
|
88
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.5.2
|
89
75
|
signing_key:
|
90
76
|
specification_version: 3
|
91
77
|
summary: I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !
|