问题
I've found that Rails allows for generic i18n of submit buttons via the following in config/locales/en.yml
:
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. I'd like the text to read as "Upload %{model}" or just "Upload". How can I make this change for just one model (e.g.: a Photo
model)?
回答1:
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. The inline docs also mention that you can do this.
回答2:
If you use the i18n-debug gem, the rails server will print translations look-up attempts to the console, like:
[i18n-debug] en.helpers.submit.post.create => nil
来源:https://stackoverflow.com/questions/13547144/i18n-for-model-specific-rails-submit-button