rails i18n association

时间:2013-04-04 11:33:50

标签: ruby-on-rails-3.2 associations rails-i18n

我遇到有关i18n在轨道上遇到嫌疑人时的问题

class User
  belongs_to :billing_address, :class_name => "Address'
  belongs_to :delivery_address, :class_name => "Address'
end

en:
  activerecord:
    attributes:
      user:
        billing_address_id: "billing address"
        delivery_address_id: "delivery address"

以上代码有效,但我想知道是否有另一种方法可以通过在yml中不使用_id后缀来实现这一目的?

1 个答案:

答案 0 :(得分:0)

你正朝着正确的方向前进。这会好一点:

en:
  activerecord:
    models:
      address: 'Address'
      user: 'User'
    attributes:
      address:
        city: 'City'
        zip_code: 'ZIP code'
      user:
        address_id: 'Address ID'

查看http://xyzpub.com/en/ruby-on-rails/3.2/i18n_mehrsprachige_rails_applikation.html