Search code examples
ruby-on-railsinternationalizationmodels

Rails: Translating Submit Actions Such As Create Or Update


It's possible to add translations of model names, such as:

en:
  activerecord:
    models:
      user: "Account"

This would change the default text of a form submit button to Create Account instead of Create User. Is there also a way to translate Create itself, ideally by model. For instance, in the user model it might be translated to Activate Account while in the invitations model it might be Send Invite.


Solution

  • Absolutely.

    Those strings come from the i18n gem, and their definitions are here:

    https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml#L136

    If you overwrite those exact translation keys(helpers.submit.create, etc.), you'll be all set.