4
通常的方法來翻譯模式和屬性Rails項目的名稱是:如何翻譯Rails引擎的模型和屬性名稱?
MyModel.model_name.human
MyModel.human_attribute_name :myattribute
,或者當您使用形式爲MyModel:
form.label :myattribute
區域設置文件config/locales/en.yml
看起來是這樣的:
en:
activerecord:
models:
mymodel:
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
mymodel:
myattribute: translated attribute
這適用於普通的Rails項目。試圖讓當
en:
my_engine:
activerecord:
models:
mymodel:
one: TranslatedMyModel
other: TranslatedMyModels
attributes:
mymodel:
myattribute: translated attribute
的my_engine前綴適用於各種翻譯,除了:當同一型號將被稱爲MyEngine
的發動機的一部分,同樣會被放入引擎config/locales/en.yml
與my_engine前綴模型或屬性名稱通過上述方法。
我建立了一個新的Rails項目和Engine with Rails 3.2.11來測試,但沒有成功。
有誰知道如何使這項工作?