module RailsStuff::Helpers::Translation
Attributes
i18n_raise[W]
Public Class Methods
i18n_raise()
click to toggle source
# File lib/rails_stuff/helpers/translation.rb, line 5 def i18n_raise @i18n_raise ||= defined?(Rails) && ActionView::Base.raise_on_missing_translations end
Public Instance Methods
translate_action(action)
click to toggle source
Translates & caches actions within `helpers.actions` scope.
# File lib/rails_stuff/helpers/translation.rb, line 13 def translate_action(action) @translate_action ||= Hash.new do |h, key| h[key] = I18n.t("helpers.actions.#{key}", raise: Translation.i18n_raise) end @translate_action[action] end
translate_confirmation(action)
click to toggle source
Translates & caches confirmations within `helpers.confirmations` scope.
# File lib/rails_stuff/helpers/translation.rb, line 21 def translate_confirmation(action) @translate_confirmation ||= Hash.new do |h, key| h[key] = I18n.t("helpers.confirmations.#{key}", default: [:'helpers.confirm'], raise: Translation.i18n_raise, ) end @translate_confirmation[action] end
yes_no(val)
click to toggle source
Translates boolean values.
# File lib/rails_stuff/helpers/translation.rb, line 32 def yes_no(val) @translate_yes_no ||= Hash.new do |h, key| h[key] = I18n.t("helpers.yes_no.#{key}", raise: Translation.i18n_raise) end @translate_yes_no[val.to_s] end