Module: RailsStuff::Helpers::Translation
- Included in:
- All
- Defined in:
- lib/rails_stuff/helpers/translation.rb
Instance Method Summary collapse
-
#translate_action(action) ⇒ Object
Translates & caches actions within ‘helpers.actions` scope.
-
#translate_confirmation(action) ⇒ Object
Translates & caches confirmations within ‘helpers.confirmations` scope.
-
#yes_no(val) ⇒ Object
Translates boolean values.
Instance Method Details
#translate_action(action) ⇒ Object
Translates & caches actions within ‘helpers.actions` scope.
5 6 7 8 9 10 |
# File 'lib/rails_stuff/helpers/translation.rb', line 5 def translate_action(action) @translate_action ||= Hash.new do |h, key| h[key] = I18n.t("helpers.actions.#{key}") end @translate_action[action] end |
#translate_confirmation(action) ⇒ Object
Translates & caches confirmations within ‘helpers.confirmations` scope.
13 14 15 16 17 18 |
# File 'lib/rails_stuff/helpers/translation.rb', line 13 def translate_confirmation(action) @translate_confirmation ||= Hash.new do |h, key| h[key] = I18n.t("helpers.confirmations.#{key}", default: [:'helpers.confirm']) end @translate_confirmation[action] end |
#yes_no(val) ⇒ Object
Translates boolean values.
21 22 23 24 25 26 |
# File 'lib/rails_stuff/helpers/translation.rb', line 21 def yes_no(val) @translate_yes_no ||= Hash.new do |h, key| h[key] = I18n.t("helpers.yes_no.#{key}") end @translate_yes_no[val.to_s] end |