Ruby on rails Rails 3 ActiveForm国际化(i18n)

Ruby on rails Rails 3 ActiveForm国际化(i18n),ruby-on-rails,internationalization,activemodel,Ruby On Rails,Internationalization,Activemodel,我有一个Rails 3.1.1项目,使用Gem作为ActiveModel的扩展来验证非持久性模型。在我的i18n yml文件中,我有以下代码: activemodel: attributes: contact_form: name: "Name" phone: "Telefon" errors: models: contact_form: attributes: name: b

我有一个Rails 3.1.1项目,使用Gem作为ActiveModel的扩展来验证非持久性模型。在我的i18n yml文件中,我有以下代码:

activemodel:
  attributes:
    contact_form:
      name: "Name"
      phone: "Telefon"
  errors:
    models:
      contact_form:
        attributes:
          name:
            blank: "Sie müssen Ihren Namen angeben."
          phone:
            blank: "Sie müssen eine Telefonnummer angeben." 
当我使用
@contact\u form.errors.full\u messages
获取所有错误消息时,在我的视图中,消息会被翻译,但属性不会被翻译,如:

Phone Sie müssen eine Telefonnummer angeben.
Phone也应翻译成Telefon


当我对持久化模型和ActiveRecord做同样的事情时,这是否有效?有人能告诉我属性转换与ActiveRecord和ActiveModel的区别吗?

经过研究,我发现了这个问题。ActiveFrom中的一个bug没有使用i18n翻译。我已经修复了这个问题,并创建了一个新的gem
rails3-active\u表单

你可以在

然后将此行添加到您的文件:

gem "rails3-active_form", "~> 2.0.0"
这也适用于您的模型:

require "active_form"

class ContactForm < ActiveForm
  attr_accessor :name, :email, :contact_number, :address, :purpose

  # ...
end 
需要“活动表单”
类ContactForm