When I submit a form with an error in it, it returns an error message. How can I translate these error messages with i18n? I already have translation for all the other texts in
The rails I18n guide covers this pretty well.
You can put the following in config/locales/nl.yml
to translate the attributes:
nl:
activerecord:
models:
user: "User"
attributes:
email: "Email"
For the error messages, ActiveRecord will look them up in the following namespaces:
activerecord.errors.models.[model_name].attributes.[attribute_name]
activerecord.errors.models.[model_name]
activerecord.errors.messages
errors.attributes.[attribute_name]
errors.messages
model
, attribute
and value
are interpolated and available in your translations, for example:
nl:
errors:
messages:
blank: "Please fill the %{model}'s %{attribute}"