Error message translation

I have a problem with translation of english phrase when an input error
occurs. When I put: error_messages_for(“registratie”) above my view. I
get the error: “xx errors prohibited this registratie from being saved”.

The problem now is, the site is for dutch customers and I would like to
translate this to a dutch phrase. I know I can translate the individual
fields with the :message attribuut. But how can i customize errors on a
level higher? Is there some file in the rails directory wich I can
adjust? Can I just override it somewhere in my rails application?

I searched at google but couldnt find something usefull

Thnx in advance.

If you look at the Rails API, you can see the the source of the method:

def error_messages_for(object_name, options = {})
options = options.symbolize_keys
object = instance_variable_get("@#{object_name}")
if object && !object.errors.empty?
content_tag(“div”,
content_tag(
options[:header_tag] || “h2”,
“#{pluralize(object.errors.count, “error”)} prohibited this
#{object_name.to_s.gsub(”_", " “)} from being saved”
) +
content_tag(“p”, “There were problems with the following fields:”) +
content_tag(“ul”, object.errors.full_messages.collect { |msg|
content_tag(“li”, msg) }),
“id” => options[:id] || “errorExplanation”, “class” =>
options[:class] || “errorExplanation”
)
else
“”
end
end

Modify this and override it, or just modify the file in place:
vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb

Ah thank you, that was what I was looking for. I have overwritten this
method in the helper which was made for the relevant view and it works
perfect :slight_smile: