[英]I18n for model-specific Rails submit button
I've found that Rails allows for generic i18n of submit buttons via the following in config/locales/en.yml
: 我发现Rails允许通过以下
config/locales/en.yml
通用i18n提交按钮:
en:
helpers:
submit:
create: "Create %{model}"
submit: "Save %{model}"
update: "Update %{model}"
However, I'm looking to update the create
value only for one specific model. 但是,我希望仅为一个特定模型更新
create
值。 I'd like the text to read as "Upload %{model}" or just "Upload". 我希望文本显示为“上传%{model}”或只是“上传”。 How can I make this change for just one model (eg: a
Photo
model)? 如何仅针对一个模型进行此更改(例如:
Photo
模型)?
From the source code , it looks like you should be able to do this: 从源代码看 ,您应该能够这样做:
en:
helpers:
submit:
post:
create: "Upload %{model}"
where post
is the name of your model. 其中
post
是模型的名称。 The inline docs also mention that you can do this. 内联文档还提到您可以这样做。
如果您使用i18n-debug gem ,则rails服务器将打印对控制台的翻译查找尝试,例如:
[i18n-debug] en.helpers.submit.post.create => nil
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.