Module: Effective::Resources::I18n

Included in:
Effective::Resource
Defined in:
app/models/effective/resources/i18n.rb

Instance Method Summary collapse

Instance Method Details

#human_action_confirm(action) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/models/effective/resources/i18n.rb', line 21

def human_action_confirm(action)
  if klass.respond_to?(:model_name)
    value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}_confirm")
    return value unless value.start_with?('translation missing:')
  end

  "Really #{human_action_name(action)} @resource?"
end

#human_action_name(action) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/effective/resources/i18n.rb', line 7

def human_action_name(action)
  if klass.respond_to?(:model_name)
    value = ::I18n.t("activerecord.actions.#{klass.model_name.i18n_key}.#{action}")
    return value unless value.start_with?('translation missing:')
  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_nameObject



30
31
32
33
34
35
36
# File 'app/models/effective/resources/i18n.rb', line 30

def human_name
  if klass.respond_to?(:model_name)
    klass.model_name.human
  else
    name.gsub('::', ' ').underscore.gsub('_', ' ')
  end
end

#human_plural_nameObject



38
39
40
41
42
43
44
# File 'app/models/effective/resources/i18n.rb', line 38

def human_plural_name
  if klass.respond_to?(:model_name)
    klass.model_name.human.pluralize
  else
    name.pluralize.gsub('::', ' ').underscore.gsub('_', ' ')
  end
end