我对 mongoid 和模型翻译有疑问。当我尝试在我的模型上使用 mongoDB 时,我不知道要翻译属性和模型名称。它通常在 *.yml 文件中,但此时这不起作用。有任何想法吗?
问问题
3843 次
4 回答
15
“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"
#...
于 2011-09-14T09:51:24.180 回答
7
在 yml 文件中试试这个(在我的例子中是 config/locales/pt-BR.yml):
activemodel:
attributes:
[model_name]:
[attribute1]: "[translation1]"
[attribute2]: "[translation2]"
[attribute3]: "[translation3]"
为我工作,使用 mongoid 2.0.0.beta.17 和 rails 3.0.0
于 2010-10-24T17:24:02.847 回答
0
像这样使用:
mongoid:
attributes:
article:
title: "Article title"
于 2015-03-30T07:10:54.990 回答
0
如果您使用引擎,您将拥有模型的命名空间
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
我使用this issue的评论解决了它。
于 2018-03-26T15:49:09.943 回答