如何在rails中转换模型名称以获取locale yml文件中的错误消息?

时间:2012-09-13 15:22:09

标签: ruby-on-rails internationalization

我想在rails自动生成的错误消息中翻译模型的名称。

当我尝试为用户创建新帐户时,我的rails应用程序中出现以下视图错误。

AccountSmall is not valid

这是正确的,因为新帐户的名称应该存在。

我现在如何通过我的yml语言环境翻译AccountSmall名称?

我试了这个没有运气:

de:
  # ...
  activerecord:
    models:
      AccountSmall: "Konto"

非常感谢提前!

1 个答案:

答案 0 :(得分:5)

而不是AccountSmall使用account_small作为您的语言环境中的键,如下所示:

de:
  activerecord:
    models:
      account_small: "Konto"