Module: I18n

Defined in:
lib/generators/genderize/templates/i18n.rb

Class Method Summary collapse

Class Method Details

.old_translateObject



5
# File 'lib/generators/genderize/templates/i18n.rb', line 5

alias :old_translate :translate

.translate(key, options = {}) ⇒ Object Also known as: t



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/genderize/templates/i18n.rb', line 6

def translate(key, options = {})
  male = is_male?(options.delete(:gender))
  res = old_translate(key, options)
  return res if male.nil?
  return res.gsub(/\[\[.+\]\]/) do |s|
    ending = s[2..-3].split(',')
    case ending.size
    when 1
      male ? '' : ending[0]
    when 2
      ending[male ? 0 : 1]
    else
      raise "unknow terminaison format '#{s}'"
    end
  end
end