Ruby on rails 3 设计i18n资源

Ruby on rails 3 设计i18n资源,ruby-on-rails-3,resources,internationalization,devise,Ruby On Rails 3,Resources,Internationalization,Devise,我正在尝试使用locale将designe默认语言(英语)翻译成葡萄牙语。我已经找到了一个很好的资源,它在大部分情况下都能工作,但是每当我在语言环境中有一个指向资源变量的指针时,它就会给我一个英文名称。例如,我有一个名为User的模型,因此当更新此用户时出现问题时,我希望显示一条包含“User”正确翻译的flash消息,在本例中为“Usuário”。模型名称翻译应放在config/locales/pt.yml pt: activerecord: models: user:

我正在尝试使用locale将designe默认语言(英语)翻译成葡萄牙语。我已经找到了一个很好的资源,它在大部分情况下都能工作,但是每当我在语言环境中有一个指向资源变量的指针时,它就会给我一个英文名称。例如,我有一个名为User的模型,因此当更新此用户时出现问题时,我希望显示一条包含“User”正确翻译的flash消息,在本例中为“Usuário”。

模型名称翻译应放在
config/locales/pt.yml

pt:
  activerecord:
    models:
      user: Usuário

Desive不使用ActiveRecord翻译,可能不与任何ORM结合使用

我刚刚用ActiveRecord键覆盖了Desive视图添加翻译:

h2 =t('.sign_up')
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f|
  = f.error_notification
  = display_base_errors resource
  = f.input :name, label: t('activerecord.attributes.user.name'), :autofocus => true
  = f.input :email, label: t('activerecord.attributes.user.email'), :required => true
  = f.input :password, label: t('activerecord.attributes.user.password'),:required => true
  = f.input :password_confirmation, label: t('activerecord.attributes.user.password_confirmation'), :required => true
  = f.button :submit, t('.sign_up'), :class => 'btn-primary'
= render "devise/shared/links"

要翻译其他消息(而不是字段标签),您应该尝试

您的语言环境是否设置为葡萄牙语?哪些确切的信息没有被翻译?是的,设置正确。好的,只有资源上的错误消息。区域设置配置中的条目如下:在errors/messages/not_saved下:one:“Não foi possível gravaro%{resource}:1 erro”如果我将“resource”更改为“model”,则表示它缺少插值参数。这不起作用,因为designe使用某种“resource”而不是ActiveRecord对象。查看Deviate::RegistrationController.new