1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
From: Gunnar Wolf <gwolf@debian.org
Bug: http://rubyforge.org/tracker/index.php?func=detail&aid=28280&group_id=855&atid=3377
Forwarded: yes
Last-Update: 2010-06-05
Description: Incomplete substitution on strings in localize_error_message (validations.rb)
This patch fixes an incomplete hash being given to the format string,
which caused some strings to raise an exception.
===================================================================
--- libgettext-activerecord-ruby-2.1.0.orig/lib/gettext_activerecord/validations.rb 2010-06-05 19:54:08.000000000 -0500
+++ libgettext-activerecord-ruby-2.1.0/lib/gettext_activerecord/validations.rb 2010-06-05 19:54:55.000000000 -0500
@@ -163,16 +163,15 @@
msgstr = @base.gettext(msgid)
msgstr = _(msgid) if msgstr == msgid
msgstr = msgstr.gsub("%{fn}", "%{attribute}").gsub("%d", "%{count}").gsub("%{val}", "%{value}") # for backward compatibility.
+ attrname = @base.class.human_attribute_name(attr)
if attr == "base"
full_message = msgstr
- elsif /%\{attribute\}/ =~ msgstr
- full_message = msgstr % {:attribute => @base.class.human_attribute_name(attr)}
elsif append_field
- full_message = @base.class.human_attribute_name(attr) + " " + msgstr
+ full_message = attrname + " " + msgstr
else
full_message = msgstr
end
- full_message % {:count => count, :value => value}
+ full_message % {:count => count, :value => value, :attribute => attrname}
end
def localize_error_messages(append_field = true) # :nodoc:
|