Module: ActionView::Helpers::ActiveRecordHelper::L10n
- Includes:
- GetText
- Defined in:
- lib/gettext/rails.rb
Constant Summary
Constants included from GetText
Class Method Summary collapse
- .error_messages_for(instance, objects, object_names, count, options) ⇒ Object
-
.set_error_message_explanation(msg, plural_msg = nil) ⇒ Object
call-seq: set_error_message_explanation(msg).
-
.set_error_message_title(msg, plural_msg = nil) ⇒ Object
call-seq: set_error_message_title(msgs).
Methods included from GetText
N_, #Nn_, _, #add_default_locale_path, bindtextdomain, #bindtextdomain_to, bound_target, bound_targets, cached=, cached?, cgi, cgi=, clear_cache, create_mofiles, current_textdomain_info, each_textdomain, find_targets, gettext, included, locale, locale=, msgmerge, msgmerge_all, n_, ngettext, ns_, nsgettext, output_charset, output_charset=, rgettext, rmsgfmt, rmsgmerge, s_, set_cgi, set_locale, set_locale_all, set_output_charset, setlocale, sgettext, textdomain, #textdomain_to, update_pofiles
Class Method Details
.error_messages_for(instance, objects, object_names, count, options) ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/gettext/rails.rb', line 334 def (instance, objects, object_names, count, ) record = ActiveRecord::Base.human_attribute_table_name_for_error([:object_name] || object_names[0].to_s) html = {} [:id, :class].each do |key| if .include?(key) value = [key] html[key] = value unless value.blank? else html[key] = 'errorExplanation' end end if [:message_title] = instance.([:message_title], count) % {:num => count, :record => record} else = n_(, count) % {:num => count, :record => record} end if [:message_explanation] = instance.([:message_explanation], count) % {:num => count} else = n_(, count) % {:num => count} end = objects.map {|object| object.errors..map {|msg| instance.content_tag(:li, msg) } } instance.content_tag(:div, instance.content_tag([:header_tag] || :h2, ) << instance.content_tag(:p, ) << instance.content_tag(:ul, ), html ) end |
.set_error_message_explanation(msg, plural_msg = nil) ⇒ Object
call-seq: set_error_message_explanation(msg)
Sets a your own explanation of the error message dialog.
-
msg: [single_msg, plural_msg]. Usually you need to call this with Nn_().
-
Returns: [single_msg, plural_msg]
323 324 325 326 327 328 329 330 331 |
# File 'lib/gettext/rails.rb', line 323 def (msg, plural_msg = nil) if msg.kind_of? Array single_msg = msg[0] plural_msg = msg[1] else single_msg = msg end = [single_msg, plural_msg] end |
.set_error_message_title(msg, plural_msg = nil) ⇒ Object
call-seq: set_error_message_title(msgs)
Sets a your own title of error message dialog.
-
msgs: [single_msg, plural_msg]. Usually you need to call this with Nn_().
-
Returns: [single_msg, plural_msg]
307 308 309 310 311 312 313 314 315 |
# File 'lib/gettext/rails.rb', line 307 def (msg, plural_msg = nil) if msg.kind_of? Array single_msg = msg[0] plural_msg = msg[1] else single_msg = msg end = [single_msg, plural_msg] end |