1
votes

I'm having some problems with Rails I18n, more specifically with the keys in errors.messages.

The issue is that Rails itself define some translations ( https://github.com/svenfuchs/rails-i18n/blob/a7d33d1b319bdbaa1da64ced0aa0d280891a3a09/rails/locale/en.yml#L101 ). Example:

  errors:
    messages:
      accepted: must be accepted
      blank: can't be blank
      present: must be blank
      confirmation: doesn't match %{attribute}
      empty: can't be empty
    ...

But Devise also defines some translations in errors.messages ( https://github.com/tigrish/devise-i18n/blob/ab598c6fdd8a029c9853fcf22788c27b828fae31/rails/locales/en.yml#L50 ). Example:

  errors:
    messages:
      already_confirmed: was already confirmed, please try signing in
      confirmation_period_expired: needs to be confirmed within %{period}, please request a new one
      expired: has expired, please request a new one
      not_found: not found
      not_locked: was not locked

If Devise translation file is loaded before Rails translation file, it will be overwritten and vice-versa.

Is there a solution for this besides merging these keys manually in the same file?

1

1 Answers

0
votes

You need not curb both the files together,

You can do the devise specific translations using the devise.es.yml in your config/locales folder. See here: https://github.com/plataformatec/devise/wiki/I18n

while having your other messages in en.yml

Hope it helps!