i18n_routing 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +1 -3
- data/lib/i18n_routing_common.rb +10 -7
- data/lib/i18n_routing_rails2.rb +2 -2
- data/lib/i18n_routing_rails3.rb +2 -2
- data/spec/i18n_routing/i18n_spec.rb +2 -2
- data/spec/locales/fr.yml +2 -2
- metadata +4 -7
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -6,13 +6,11 @@ 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
|
9
|
+
Works with Rails 2.3 and Rails3 beta4 !
|
10
10
|
|
11
11
|
== TODO for next releases (written the 9th of June)
|
12
12
|
|
13
13
|
* Handle multiple translations for same resources name (Example: nested and not nested resources)
|
14
|
-
* Find a way to force translation when the translation is the same
|
15
|
-
* Do the translation if only the path names are translated and not the path
|
16
14
|
* Handle namespace translation
|
17
15
|
|
18
16
|
== I18n gem version warning
|
data/lib/i18n_routing_common.rb
CHANGED
@@ -7,16 +7,19 @@ module I18nRouting
|
|
7
7
|
|
8
8
|
# First, if an option is given, try to get the translation in the routes scope
|
9
9
|
if option
|
10
|
-
|
11
|
-
|
12
|
-
return (t
|
10
|
+
default = "{option}Noi18nRoutingTranslation"
|
11
|
+
t = I18n.t(option, :scope => "routes.#{name}.#{type}", :default => default)
|
12
|
+
return (t == default ? nil : t)
|
13
13
|
else
|
14
|
+
default = "{name}Noi18nRoutingTranslation"
|
15
|
+
|
14
16
|
# Try to get the translation in routes namescope first
|
15
|
-
t = I18n.t(:as, :scope => "routes.#{name}", :default =>
|
16
|
-
|
17
|
-
return t if t and t !=
|
17
|
+
t = I18n.t(:as, :scope => "routes.#{name}", :default => default)
|
18
|
+
|
19
|
+
return t if t and t != default
|
18
20
|
|
19
|
-
I18n.t(name.to_s, :scope => type, :default =>
|
21
|
+
t = I18n.t(name.to_s, :scope => type, :default => default)
|
22
|
+
return (t == default ? nil : t)
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
data/lib/i18n_routing_rails2.rb
CHANGED
@@ -99,7 +99,7 @@ module ActionController
|
|
99
99
|
@locales.each do |l|
|
100
100
|
I18n.locale = l
|
101
101
|
nt = "#{l}_#{name}"
|
102
|
-
if nt != name and (
|
102
|
+
if nt != name and (t = I18nRouting.translation_for(path, :named_routes_path))
|
103
103
|
gl_add_named_route(nt, t, options.merge(:glang => l))
|
104
104
|
puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', name, l, t]) if @i18n_verbose
|
105
105
|
end
|
@@ -169,7 +169,7 @@ module ActionController
|
|
169
169
|
locales.each do |l|
|
170
170
|
I18n.locale = l
|
171
171
|
nt = "#{l}_#{name}"
|
172
|
-
if nt != name and (
|
172
|
+
if nt != name and (t = I18nRouting.translation_for(name, namespace))
|
173
173
|
nt = "#{l}_#{name}"
|
174
174
|
opts[:as] = t
|
175
175
|
opts[:glang] = l
|
data/lib/i18n_routing_rails3.rb
CHANGED
@@ -36,7 +36,7 @@ module I18nRouting
|
|
36
36
|
localized_path = I18nRouting.translation_for(resource.name, type)
|
37
37
|
|
38
38
|
# A translated route exists :
|
39
|
-
if localized_path and
|
39
|
+
if localized_path and String === localized_path
|
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
|
@@ -279,7 +279,7 @@ module I18nRouting
|
|
279
279
|
# try to get translated path :
|
280
280
|
I18n.locale = locale
|
281
281
|
ts = @path.gsub(/^\//, '')
|
282
|
-
@localized_path = '/' + I18nRouting.translation_for(ts, :named_routes_path)
|
282
|
+
@localized_path = '/' + (I18nRouting.translation_for(ts, :named_routes_path) || ts)
|
283
283
|
|
284
284
|
# If a translated path exists, set localized infos
|
285
285
|
if @localized_path and @localized_path != @path
|
@@ -193,7 +193,7 @@ describe :localized_routes do
|
|
193
193
|
routes.send(:author_books_path, 1).should == "/#{I18n.t :authors, :scope => :resources}/1/#{I18n.t :books, :scope => :resources}"
|
194
194
|
end
|
195
195
|
|
196
|
-
it "deep nested resources generate routes using localized values" do
|
196
|
+
it "deep nested resources generate routes using localized values and translate routes even translated name is the same" do
|
197
197
|
routes.send(:universes_path).should == "/#{I18n.t :universes, :scope => :resources}"
|
198
198
|
routes.send(:universe_galaxies_path, 1).should == "/#{I18n.t :universes, :scope => :resources}/1/#{I18n.t :galaxies, :scope => :resources}"
|
199
199
|
routes.send(:universe_galaxy_planets_path, 1, 1).should == "/#{I18n.t :universes, :scope => :resources}/1/#{I18n.t :galaxies, :scope => :resources}/1/#{I18n.t :planets, :scope => :resources}"
|
@@ -211,7 +211,7 @@ describe :localized_routes do
|
|
211
211
|
routes.send(:new_user_path).should == "/#{I18n.t :users, :scope => :resources}/#{I18n.t :new, :scope => :'routes.users.path_names'}"
|
212
212
|
routes.send(:edit_user_path, 42).should == "/#{I18n.t :users, :scope => :resources}/42/#{I18n.t :edit, :scope => :'routes.users.path_names'}"
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
end
|
216
216
|
|
217
217
|
context "with member and collection" do
|
data/spec/locales/fr.yml
CHANGED
@@ -11,7 +11,7 @@ fr:
|
|
11
11
|
users: utilisateurs
|
12
12
|
authors: 'auteurs'
|
13
13
|
books: 'livres'
|
14
|
-
galaxies: 'galaxies
|
14
|
+
galaxies: 'galaxies'
|
15
15
|
planets: 'planetes'
|
16
16
|
universes: 'univers'
|
17
17
|
countries: 'pays'
|
@@ -24,4 +24,4 @@ fr:
|
|
24
24
|
about: 'a-propos'
|
25
25
|
path_names:
|
26
26
|
new: 'nouveau'
|
27
|
-
edit: 'edition'
|
27
|
+
edit: 'edition'
|
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
|
+
- 6
|
9
|
+
version: 0.3.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Guillaume Luccisano
|
@@ -14,14 +14,13 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-13 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
|
25
24
|
requirements:
|
26
25
|
- - ">"
|
27
26
|
- !ruby/object:Gem::Version
|
@@ -64,7 +63,6 @@ rdoc_options: []
|
|
64
63
|
require_paths:
|
65
64
|
- lib
|
66
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
66
|
requirements:
|
69
67
|
- - ">="
|
70
68
|
- !ruby/object:Gem::Version
|
@@ -72,7 +70,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
70
|
- 0
|
73
71
|
version: "0"
|
74
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
73
|
requirements:
|
77
74
|
- - ">="
|
78
75
|
- !ruby/object:Gem::Version
|
@@ -84,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
81
|
requirements: []
|
85
82
|
|
86
83
|
rubyforge_project: i18n_routing
|
87
|
-
rubygems_version: 1.3.
|
84
|
+
rubygems_version: 1.3.6
|
88
85
|
signing_key:
|
89
86
|
specification_version: 3
|
90
87
|
summary: I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !
|