Module: GenericFormFor::I18n
- Included in:
- Actions::Base, Helpers::ActionsHelper, Helpers::FieldsetHelper, GenericFormFor::Inputs::Base
- Defined in:
- lib/generic_form_for/i18n.rb
Instance Method Summary collapse
- #translate(value, &block) ⇒ Object
- #translate_action(value) ⇒ Object
- #translate_hint(value) ⇒ Object
- #translate_label(value) ⇒ Object
- #translate_legend(value) ⇒ Object
- #translate_placeholder(value) ⇒ Object
Instance Method Details
#translate(value, &block) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/generic_form_for/i18n.rb', line 34 def translate(value, &block) if value.is_a?(Symbol) return yield if builder.use_translations value.to_s.camelize else value end end |
#translate_action(value) ⇒ Object
22 23 24 25 26 |
# File 'lib/generic_form_for/i18n.rb', line 22 def translate_action(value) translate(value) do ::I18n.translate(value, :scope => "form_for.actions", :default => Proc.new{:"actions.#{value}"}) end end |
#translate_hint(value) ⇒ Object
10 11 12 13 14 |
# File 'lib/generic_form_for/i18n.rb', line 10 def translate_hint(value) translate(value) do ::I18n.translate(value, :scope => "form_for.#{object_name}.hints") end end |
#translate_label(value) ⇒ Object
16 17 18 19 20 |
# File 'lib/generic_form_for/i18n.rb', line 16 def translate_label(value) translate(value) do ::I18n.translate(value, :scope => "activerecord.attributes.#{object_name}", :default => Proc.new{:"form_for.#{object_name}.attributes.#{value}"}) end end |
#translate_legend(value) ⇒ Object
28 29 30 31 32 |
# File 'lib/generic_form_for/i18n.rb', line 28 def translate_legend(value) translate(value) do ::I18n.translate(value, :scope => "form_for.#{object_name}.legends", :default => Proc.new{:"legends.#{value}"}) end end |
#translate_placeholder(value) ⇒ Object
4 5 6 7 8 |
# File 'lib/generic_form_for/i18n.rb', line 4 def translate_placeholder(value) translate(value) do ::I18n.translate(value, :scope => "form_for.#{object_name}.placeholders") end end |