module Interage::TranslationHelper

Public Instance Methods

ta(model, attribute, count = 1)
tb(value)
Alias for: translate_boolean
tbci(value)
tbi(value)
tm(model, count = 1)
tmp(model)
translate_boolean(value) click to toggle source

Public: Translate a boolean attribute.

value: TrueClass or FalseClass.

Examples

<%= tb true %>
# => 'Sim'

<%= tb false %>
# => 'Nao'

Returns translated boolean's attribute.

# File lib/interage/translation_helper.rb, line 76
def translate_boolean(value)
  value ? t('boolean.truly') : t('boolean.falsely')
end
Also aliased as: tb
translate_boolean_in_check_box_icon(value) click to toggle source

Public: Translate a boolean attribute in an icon.

value: TrueClass or FalseClass.

Examples

<%= tbci true %>
# => '<i class="fa fa-check-square-o text-default"></i>'

<%= tbci false %>
# => '<i class="fa fa-square-o text-default"></i>'

Returns translated boolean's attribute in an icon.

# File lib/interage/translation_helper.rb, line 118
def translate_boolean_in_check_box_icon(value)
  if value
    app_icon('check', class: 'text-success')
  else
    app_icon('times', class: 'text-danger')
  end
end
Also aliased as: tbci
translate_boolean_in_icon(value) click to toggle source

Public: Translate a boolean attribute in an icon.

value: TrueClass or FalseClass.

Examples

<%= tbi true %>
# => '<i class="fa fa-check text-success"></i>'

<%= tbi false %>
# => '<i class="fa fa-times text-danger"></i>'

Returns translated boolean's attribute in an icon.

# File lib/interage/translation_helper.rb, line 95
def translate_boolean_in_icon(value)
  if value
    content_tag(:span, '✓', class: 'text-success')
  else
    content_tag(:span, '×', class: 'text-danger')
  end
end
Also aliased as: tbi
translate_model_attribute(model, attribute, count = 1) click to toggle source

Public: Translate a model attribute.

model: Model class. attribute: Attribute name. count: Count.

Examples

<%= ta Post, :title %>
# => 'Titulo'

<%= ta Post, :title, 2 %>
# => 'Titulos'

Returns translated model's attribute.

# File lib/interage/translation_helper.rb, line 57
def translate_model_attribute(model, attribute, count = 1)
  model.human_attribute_name(attribute, count: count)
end
Also aliased as: ta
translate_model_name(model, count = 1) click to toggle source

Public: Translate a model name.

model: Model class. count: Count.

Examples:

<%= tm Post %>
# => 'Artigo'

<%= tm Post, 2 %>
# => 'Artigos'

Returns translated model.

# File lib/interage/translation_helper.rb, line 20
def translate_model_name(model, count = 1)
  model.model_name.human(count: count)
end
Also aliased as: tm
translate_model_name_pluralized(model) click to toggle source

Public: Translate a model name pluralized.

model: Model class.

Examples:

<%= tm Post %>
# => 'Artigos'

Returns translated model pluralized.

# File lib/interage/translation_helper.rb, line 36
def translate_model_name_pluralized(model)
  translate_model_name(model, 2)
end
Also aliased as: tmp