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=, charset=, clear_cache, create_mofiles, current_textdomain_info, each_textdomain, gettext, included, locale, locale=, msgmerge, msgmerge_all, n_, ngettext, ns_, nsgettext, output_charset, output_charset=, rgettext, rmsgfmt, rmsgmerge, s_, set_cgi, set_charset, 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
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/gettext/rails.rb', line 332 def (instance, objects, object_names, count, ) record = ActiveRecord::Base.human_attribute_table_name_for_error([:object_name] || object_names[0].to_s) = instance.(@error_message_title) = instance.(@error_message_explanation) html = {} [:id, :class].each do |key| if .include?(key) value = [key] html[key] = value unless value.blank? else html[key] = 'errorExplanation' end end = n_(, count) % {:num => count, :record => record} = 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, n_(, count) % {:num => count}) << 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]
321 322 323 324 325 326 327 328 329 |
# File 'lib/gettext/rails.rb', line 321 def (msg, plural_msg = nil) if msg.kind_of? Array single_msg = msg[0] plural_msg = msg[1] else single_msg = msg end @error_message_explanation = [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]
305 306 307 308 309 310 311 312 313 |
# File 'lib/gettext/rails.rb', line 305 def (msg, plural_msg = nil) if msg.kind_of? Array single_msg = msg[0] plural_msg = msg[1] else single_msg = msg end @error_message_title = [single_msg, plural_msg] end |