mercredi 16 décembre 2015

Rails i18n: merge translations from several sources

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 ( http://ift.tt/1O94hNl ). 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 ( http://ift.tt/1T2onXI ). 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?

Aucun commentaire:

Enregistrer un commentaire