i18n_routing 0.3.4 → 0.3.5

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 CHANGED
@@ -1,3 +1,9 @@
1
+ 0.3.5 (June 9, 2010)
2
+
3
+ * Clean up some .to_sym in order to avoid unnecessary symbols during runtime
4
+ * Works with both I18n.locale as string or as symbol
5
+ * Try to fix a Pathname instead of string issue
6
+
1
7
  0.3.4 (June 3, 2010)
2
8
 
3
9
  * Fix Rails3 issue with nested single resource again and pluralize controller name as it should be
data/README.rdoc CHANGED
@@ -2,9 +2,18 @@
2
2
 
3
3
  I18n_routing is a plugin for Ruby on Rails that lets you easily translate your routes trough the I18n api included in Rails since version 2.2
4
4
 
5
- All necessary informations are available on the wiki : http://wiki.github.com/kwi/i18n_routing
5
+ All necessary informations are available on the wiki: http://wiki.github.com/kwi/i18n_routing
6
6
 
7
- Works with Rails 2.3 and Rails3 !
7
+ For any question, use the i18_routing google group: http://groups.google.com/group/i18n-routing
8
+
9
+ Works with Rails 2.3 and Rails3 beta3 !
10
+
11
+ == TODO for next releases (written the 9th of June)
12
+
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
+ * Handle namespace translation
8
17
 
9
18
  == I18n gem version warning
10
19
 
@@ -7,12 +7,12 @@ 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
- t = I18n.t(option.to_sym, :scope => "routes.#{name}.#{type}".to_sym, :default => option.to_s)
10
+ t = I18n.t(option, :scope => "routes.#{name}.#{type}", :default => option.to_s)
11
11
 
12
12
  return (t || name)
13
13
  else
14
14
  # Try to get the translation in routes namescope first
15
- t = I18n.t(:as, :scope => "routes.#{name}".to_sym, :default => name.to_s)
15
+ t = I18n.t(:as, :scope => "routes.#{name}", :default => name.to_s)
16
16
 
17
17
  return t if t and t != name.to_s
18
18
 
@@ -21,7 +21,7 @@ module ActionController
21
21
  def generation_requirements
22
22
  r = mkd_generation_requirements
23
23
  if @glang and !r.blank?
24
- r << " and I18n.locale == :#{@glang}"
24
+ r << " and I18n.locale.to_sym == :#{@glang}"
25
25
  end
26
26
 
27
27
  return r
@@ -39,7 +39,7 @@ module I18nRouting
39
39
  if localized_path and localized_path != resource.name.to_s 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
- opts[:path] = localized_path.to_sym
42
+ opts[:path] = localized_path
43
43
  opts[:controller] ||= r.to_s.pluralize
44
44
 
45
45
  res = ["#{locale}_#{r}".to_sym, opts]
@@ -146,7 +146,7 @@ module I18nRouting
146
146
  def localized(locales = I18n.available_locales, opts = {})
147
147
  # Add if not added Rails.root/config/locales/*.yml in the I18n.load_path
148
148
  if !@i18n_routing_path_set and defined?(Rails) and Rails.respond_to?(:root) and Rails.root
149
- I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml')]).uniq
149
+ I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml').to_s]).uniq
150
150
  @i18n_routing_path_set = true
151
151
  end
152
152
 
@@ -284,7 +284,7 @@ module I18nRouting
284
284
  # If a translated path exists, set localized infos
285
285
  if @localized_path and @localized_path != @path
286
286
  #@options[:controller] ||= @options[:as]
287
- @options[:as] = "#{locale}_#{@options[:as]}".to_sym
287
+ @options[:as] = "#{locale}_#{@options[:as]}"
288
288
  @path = @localized_path
289
289
  @options[:constraints] = @options[:constraints] ? @options[:constraints].dup : {}
290
290
  @options[:constraints][:i18n_locale] = locale.to_s
@@ -365,7 +365,7 @@ module I18nRouting
365
365
  # If a @locale is present and if this locale is not the current one
366
366
  # => return nil and refuse to generate the route
367
367
  def generate_with_i18n_routing(method, params = {}, recall = {}, options = {})
368
- return nil if @locale and @locale != I18n.locale
368
+ return nil if @locale and @locale != I18n.locale.to_sym
369
369
  generate_without_i18n_routing(method, params, recall, options)
370
370
  end
371
371
 
@@ -169,6 +169,13 @@ describe :localized_routes do
169
169
  routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
170
170
  end
171
171
 
172
+ it "named_route generates route using localized values and I18n.locale as a string" do
173
+ o = I18n.locale
174
+ I18n.locale = "fr"
175
+ routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
176
+ I18n.locale = o
177
+ end
178
+
172
179
  it "resource generates routes using localized values" do
173
180
  routes.send(:contact_path).should == "/#{I18n.t :contact, :scope => :resource}"
174
181
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
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-06-03 00:00:00 +02:00
17
+ date: 2010-06-09 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency