I've problem with mongoid and model translations. When I'm trying use mongoDB on my model I haven't idea to translate attributes and model name. It's normally in *.yml files but in this time this doesn't work. Any ideas?
我有mongoid和模型翻译的问题。当我尝试在我的模型上使用mongoDB时,我不知道要翻译属性和模型名称。它通常在* .yml文件中,但在这个时候这不起作用。有任何想法吗?
4 个解决方案
#1
14
Variant with "activemodel" does not work for me. But.
变体与“activemodel”对我不起作用。但。
This variant worked for me:
这个变种对我有用:
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"
#...
从这里
#2
7
Try this in the yml file (config/locales/pt-BR.yml in my case):
在yml文件中尝试这个(在我的例子中是config / locales / pt-BR.yml):
activemodel:
attributes:
[model_name]:
[attribute1]: "[translation1]"
[attribute2]: "[translation2]"
[attribute3]: "[translation3]"
Worked for me, using mongoid 2.0.0.beta.17 and rails 3.0.0
为我工作,使用mongoid 2.0.0.beta.17和rails 3.0.0
#3
0
Use like this:
使用这样:
mongoid:
attributes:
article:
title: "Article title"
Check this one: https://gist.github.com/lurkermike/1596505
检查一下:https://gist.github.com/lurkermike/1596505
#4
0
If you use engines you have o namespace the model
如果您使用引擎,则可以命名模型
en:
activerecord:
models:
'my_engine/mymodel':
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
'my_engine/mymodel':
myattribute: translated attribute
or if you use mongoid
或者如果你使用mongoid
en:
mongoid:
models:
'my_engine/mymodel':
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
'my_engine/mymodel':
myattribute: translated attribute
I solved it using comments from this issue.
我使用这个问题的评论解决了它。
#1
14
Variant with "activemodel" does not work for me. But.
变体与“activemodel”对我不起作用。但。
This variant worked for me:
这个变种对我有用:
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"
#...
从这里
#2
7
Try this in the yml file (config/locales/pt-BR.yml in my case):
在yml文件中尝试这个(在我的例子中是config / locales / pt-BR.yml):
activemodel:
attributes:
[model_name]:
[attribute1]: "[translation1]"
[attribute2]: "[translation2]"
[attribute3]: "[translation3]"
Worked for me, using mongoid 2.0.0.beta.17 and rails 3.0.0
为我工作,使用mongoid 2.0.0.beta.17和rails 3.0.0
#3
0
Use like this:
使用这样:
mongoid:
attributes:
article:
title: "Article title"
Check this one: https://gist.github.com/lurkermike/1596505
检查一下:https://gist.github.com/lurkermike/1596505
#4
0
If you use engines you have o namespace the model
如果您使用引擎,则可以命名模型
en:
activerecord:
models:
'my_engine/mymodel':
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
'my_engine/mymodel':
myattribute: translated attribute
or if you use mongoid
或者如果你使用mongoid
en:
mongoid:
models:
'my_engine/mymodel':
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
'my_engine/mymodel':
myattribute: translated attribute
I solved it using comments from this issue.
我使用这个问题的评论解决了它。