class ParentModel < ActiveRecord::Base
has_one :child, class_name: 'ChildModel'
accepts_nested_attributes_for :child
end
class ChildModel < ActiveRecord::Base
has_many :grand_childen, class_name: 'GrandChildModel'
accepts_nested_attributes_for :grand_childen
end
class GrandChildModel < ActiveRecord::Base
attr_accessible :name
end
上記の様な model が定義されている場合、 ActiveModel::Translation
内では以下のように国際化処理が行われる。
I18n.translate('activerecord.attributes.parent_model/child/grand_childen.name')
よって、ja.yml
ファイルには以下のように定義すれば良い。
ja:
activerecord:
attributes:
parent_model/child/grand_childen:
name: 孫の名前