Class: ActiveRecord::Errors
- Inherits:
-
Object
- Object
- ActiveRecord::Errors
- Extended by:
- GetText
- Includes:
- GetText
- Defined in:
- lib/gettext/rails.rb
Overview
:nodoc:
Constant Summary collapse
- RE_FIELD_NAME =
:nodoc:
/%\{fn\}/
- @@default_error_messages_d =
{ :too_long => /#{Regexp.escape([:too_long]).sub(/%d/, '(\d+)')}/, :too_short => /#{Regexp.escape([:too_short]).sub(/%d/, '(\d+)')}/, :wrong_length => /#{Regexp.escape([:wrong_length]).sub(/%d/, '(\d+)')}/, }
Constants included from GetText
Instance Method Summary collapse
-
#full_messages ⇒ Object
:nodoc:.
Methods included from GetText
N_, Nn_, _, add_default_locale_path, bindtextdomain, callersrc, cgi, cgi=, charset=, create_mofiles, gettext, locale, locale=, msgmerge, msgmerge_all, n_, ngettext, output_charset, output_charset=, rgettext, rmsgfmt, rmsgmerge, s_, set_cgi, set_charset, set_locale, set_output_charset, setlocale, sgettext, textdomain, update_pofiles
Instance Method Details
#full_messages ⇒ Object
:nodoc:
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/gettext/rails.rb', line 282 def #:nodoc: = [] @errors.each_key do |attr| @errors[attr].each do |msg| next if msg.nil? #Ugly but... :-< @@default_error_messages_d.each do |key, regexp| if regexp =~ msg msg = _([key]) % $1.to_i break end end custom_msg = @base.gettext(msg) custom_msg = _(msg) if custom_msg == msg if attr == "base" << custom_msg elsif RE_FIELD_NAME =~ msg << custom_msg % {:fn => @base.class.human_attribute_name(attr)} else << @base.class.human_attribute_name(attr) + " " + custom_msg end end end end |