Ruby on rails 什么';使用mongoid在rails中转换模型属性的方法是什么?

Ruby on rails 什么';使用mongoid在rails中转换模型属性的方法是什么?,ruby-on-rails,mongodb,ruby-on-rails-3,translation,mongoid,Ruby On Rails,Mongodb,Ruby On Rails 3,Translation,Mongoid,我对mongoid和模型翻译有问题。当我尝试在我的模型上使用mongoDB时,我不知道如何翻译属性和模型名称。它通常在*.yml文件中,但在这段时间内不起作用。有什么想法吗?在yml文件中试试这个(在我的例子中是config/locales/pt-BR.yml): 为我工作过,使用mongoid 2.0.0.beta.17和rails 3.0.0带有“activemodel”的变体对我不起作用。但是 这一变体对我有效: en: mongoid: errors: mode

我对mongoid和模型翻译有问题。当我尝试在我的模型上使用mongoDB时,我不知道如何翻译属性和模型名称。它通常在*.yml文件中,但在这段时间内不起作用。有什么想法吗?

在yml文件中试试这个(在我的例子中是config/locales/pt-BR.yml):

为我工作过,使用mongoid 2.0.0.beta.17和rails 3.0.0

带有“activemodel”的变体对我不起作用。但是

这一变体对我有效:

 en:
  mongoid:
    errors:
      models:
        user:
          attributes:
            email:
              blank: "You have to give me your e-mail address"
              not_found: "e-mail address not found in list of members"
              #...
    attributes:
      user:
        email: "Email address"
        name: "Your nickname"
        #...

像这样使用:

mongoid:
  attributes:
    article:
      title: "Article title"

勾选此项:

如果您使用引擎,则您有一个模型名称空间

en:
  activerecord:
    models:
      'my_engine/mymodel':
        one: TranslatedMyModel
        other: TranslatedMyModels
    attributes:
      'my_engine/mymodel':
        myattribute: translated attribute
或者如果您使用mongoid

en:
  mongoid:
    models:
      'my_engine/mymodel':
        one: TranslatedMyModel
        other: TranslatedMyModels
    attributes:
      'my_engine/mymodel':
        myattribute: translated attribute

我用问题中的评论解决了这个问题。

翻译模型本身的名称怎么样?mongoid 2.7.1非常适合!!
en:
  mongoid:
    models:
      'my_engine/mymodel':
        one: TranslatedMyModel
        other: TranslatedMyModels
    attributes:
      'my_engine/mymodel':
        myattribute: translated attribute