版本:
2.3.4 :011 > RUBY_VERSION
=> "2.3.4"
2.3.4 :012 > Rails::VERSION::STRING
=> "4.1.8"
后端:
2.3.4 :013 > I18n.backend
=> #<I18n::Backend::Simple:0x007fa2d84eb560 @initialized=false, @translations=nil>
安装宝石:
$ 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)
yml的内容:
---
en:
attributes:
patient:
id: "1234"
Rails控制台输出:
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"
问题:
为什么i18n查找常规路径&#34; en.patient.id&#34;但不会退缩 to&#34; en.activerecord.attributes.patient.id&#34;?