Home Why Rails i18n doesn't look up under activerecord.attributes?
Reply: 0

Why Rails i18n doesn't look up under activerecord.attributes?

user1088
1#
user1088 Published in May 23, 2018, 8:41 pm

Versions:

2.3.4 :011 > RUBY_VERSION
=> "2.3.4" 

2.3.4 :012 > Rails::VERSION::STRING
=> "4.1.8"

Backends:

2.3.4 :013 > I18n.backend
 => #<I18n::Backend::Simple:0x007fa2d84eb560 @initialized=false, @translations=nil> 

Gems installed:

$ gem list | grep -i i18n
i18n (0.9.3, 0.9.1, 0.7.0)
i18n-debug (1.1.0)
i18n-tasks (0.9.20)
i18n_yaml_sorter (0.2.0)
rails-i18n (4.0.9)

Content of the yml:

---
en:
  attributes:
    patient:
        id: "1234"

Rails console output:

2.3.4 :014 > Patient.human_attribute_name(:id)
[i18n-debug] en.activerecord.attributes.patient.id => "1234"
 => "1234" 

2.3.4 :015 > I18n.t('patient.id')
[i18n-debug] en.patient.id => nil
 => "translation missing: en.patient.id" 

Question:

Why i18n looks up regular path "en.patient.id" but does not fall back to "en.activerecord.attributes.patient.id"?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30869 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO