Class: ActiveRecord::Errors

Inherits:
Object
  • Object
show all
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(default_error_messages[:too_long]).sub(/%d/, '(\d+)')}/,
  :too_short => /#{Regexp.escape(default_error_messages[:too_short]).sub(/%d/, '(\d+)')}/,
  :wrong_length => /#{Regexp.escape(default_error_messages[:wrong_length]).sub(/%d/, '(\d+)')}/,
}

Constants included from GetText

GetText::VERSION

Instance Method Summary collapse

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_messagesObject

: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 full_messages #:nodoc:
  full_messages = []
  @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 = _(default_error_messages[key]) % $1.to_i
   break
 end
	  end
	  custom_msg = @base.gettext(msg)
	  custom_msg = _(msg) if custom_msg == msg 

	  if attr == "base"
 full_messages << custom_msg
	  elsif  RE_FIELD_NAME =~ msg
 full_messages << custom_msg % {:fn => @base.class.human_attribute_name(attr)}
	  else
 full_messages << @base.class.human_attribute_name(attr) + " " + custom_msg
	  end
	end
  end
  full_messages
end