#34 new
Javix

Interpolation in activerecord.errors.template.header.other & activerecord.errors.template.body not read

Reported by Javix | January 31st, 2011 @ 10:57 AM

I tried to translate the errors message header and body and it seems that the interpolation didn't work properly.
here is what I did in 'error_messages_helper.rb' file (I use nifty_generators gem):
[code] module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed. def error_messages_for(*objects) options = objects.extract_options!
options[:header_message] ||= t("activerecord.errors.template.header.other") options[:message] ||= t("activerecord.errors.template.body") messages = objects.compact.map { |o| o.errors.full_messages }.flatten unless messages.empty? content_tag(:div, :class => "error_messages") do list_items = messages.map { |msg| content_tag(:li, msg) } content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe) end end end

module FormBuilderAdditions def error_messages(options = {}) @template.error_messages_for(@object, options) end end end

ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
[/code] When generating a validation error, I got:
[code] "Impossible d'enregistrer %{model} : %{count} erreurs" [/code] inteads of the translated model name and count value.
I also attache the translation 'yml' file.

Comments and changes to this ticket

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff

People watching this ticket

Attachments

Pages