我发现Rails通过config/locales/en.yml
中的以下内容允许提交按钮的通用i18n:
en:
helpers:
submit:
create: "Create %{model}"
submit: "Save %{model}"
update: "Update %{model}"
但是,我希望仅针对一个特定模型更新create
值。我希望文本显示为“上传%{model}”或只是“上传”。如何仅对一个模型进行此更改(例如:a Photo
模型)?
答案 0 :(得分:42)
从source code开始,看起来你应该可以这样做:
en:
helpers:
submit:
post:
create: "Upload %{model}"
其中post
是模型的名称。 inline docs也提到你可以这样做。
答案 1 :(得分:9)
如果您使用i18n-debug gem,则rails服务器将打印对控制台的翻译查找尝试,例如:
[i18n-debug] en.helpers.submit.post.create => nil