Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure to have a Hash under the i18n keys 'activerecord.attributes…

…' and 'activerecord.models' as this might not always be the case. See issue #1662.
  • Loading branch information...
commit 1863f12713ebbecb09361f72fa5343b8728aa7a1 1 parent fb1fd61
@thoefer2 thoefer2 authored
Showing with 13 additions and 6 deletions.
  1. +13 −6 activerecord/lib/active_record/railtie.rb
View
19 activerecord/lib/active_record/railtie.rb
@@ -99,18 +99,25 @@ class Railtie < Rails::Railtie
config.after_initialize do
container = :"activerecord.attributes"
- I18n.t(container, :default => {}).each do |key, value|
- if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) }
- $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
+ lookup = I18n.t(container, :default => {})
+ if lookup.is_a?(Hash)
+ lookup.each do |key, value|
+ if value.is_a?(Hash) && value.any? { |k,v| v.is_a?(Hash) }
+ $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
+ end
end
end
container = :"activerecord.models"
- I18n.t(container, :default => {}).each do |key, value|
- if value.is_a?(Hash)
- $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
+ lookup = I18n.t(container, :default => {})
+ if lookup.is_a?(Hash)
+ lookup.each do |key, value|
+ if value.is_a?(Hash)
+ $stderr.puts "[DEPRECATION WARNING] Nested I18n namespace lookup under \"#{container}.#{key}\" is no longer supported"
+ end
end
end
end
+
end
end

3 comments on commit 1863f12

@romul

Why 'activerecord.attributes' and 'activerecord.models' namespaces are deprecated? And what is a replacement?

@dmathieu
Collaborator

This deprecation is added here : c19bd4f
It follows #1402

@romul

Ok, but what is a replacement? What I should write in locales/*.yml to avoid deprecation warnings? Currently these files contains something like:

activerecord:
  models:
    product:
      one: Товар
      other: Товары

Besides, Product.model_name.human still uses something like I18n.t(:product, :namespace => [:activerecord, :models], :count => 1) as result.
So, I don't understand why namespace, which uses in Rails code itself marked as deprecated.

Please sign in to comment.
Something went wrong with that request. Please try again.