Module: Effective::Resources::I18n
- Included in:
- Effective::Resource
- Defined in:
- app/models/effective/resources/i18n.rb
Instance Method Summary collapse
- #human_action_confirm(action) ⇒ Object
- #human_action_name(action) ⇒ Object
- #human_name ⇒ Object
- #human_plural_name ⇒ Object
Instance Method Details
#human_action_confirm(action) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/effective/resources/i18n.rb', line 22 def human_action_confirm(action) if klass.respond_to?(:model_name) key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm" value = ::I18n.t(key) return value unless value.include?(key) # missing translation end "Really #{human_action_name(action)} @resource?" end |
#human_action_name(action) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/effective/resources/i18n.rb', line 6 def human_action_name(action) if klass.respond_to?(:model_name) key = "activerecord.actions.#{klass.model_name.i18n_key}.#{action}" value = ::I18n.t(key) return value unless value.include?(key) # missing translation end if crud_actions.include?(action) # Raises exception if not present return EffectiveResources.et("effective_resources.actions.#{action}") end action.to_s.titleize end |
#human_name ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/models/effective/resources/i18n.rb', line 33 def human_name if klass.respond_to?(:model_name) klass.model_name.human else name.gsub('::', ' ').underscore.gsub('_', ' ') end end |
#human_plural_name ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/models/effective/resources/i18n.rb', line 41 def human_plural_name if klass.respond_to?(:model_name) klass.model_name.human.pluralize else name.pluralize.gsub('::', ' ').underscore.gsub('_', ' ') end end |