I'm rendering a form on a few different pages, such as: edit, new, show
. Now on the submit button it says: "update post"
and "create post"
. I know that there is a way to add custom text to the buttons <%= f.submit "Text" %>
. But because i'm rendering the form it shows that value on each of the pages. So i'm wondering if there is a way where i can add the custom text value per page, without having to copy the whole form itself.
You can use the Rails built-i I18n (internationalization) module :
# config/locales/en.yml
en:
helpers:
submit:
post:
create: "Toss me bottle to the sea!"
update: "Arg! Now she be a spellin' straight."
You need to remove the text from submit button in order for it to be translated:
<%= f.submit %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.