0

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.

nullnullnull
  • 8,039
  • 12
  • 55
  • 107

1 Answers1

2

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.

sevenseacat
  • 24,699
  • 6
  • 63
  • 88
  • Excellent. It's good to see all the defaults in one place, too. It'll help with future questions. Unfortunately, due to the way the file is structured, it looks like there's no way to have model specific action names. Still, this is quite useful for defining a new default. – nullnullnull Mar 22 '13 at 13:03
  • 1
    I haven't tried it, but I wonder if it would work if you added model-specific translations - something like `helpers.submit.user.create`? – sevenseacat Mar 22 '13 at 13:06
  • Just gave it a shot, and no luck. I'm fine with just providing a translation directly in the submit button, such as `<%= f.submit t("users.new.create_account") %>`. Based off what I read in the defaults, it might even be possible to do something like `create_account: "Create %{model}"`, thereby sparing me the need to retranslate the model name for each button. – nullnullnull Mar 22 '13 at 13:17