Module: Transmating::I18n

Extended by:
ActiveSupport::Concern
Defined in:
lib/transmating/i18n.rb

Instance Method Summary collapse

Instance Method Details

#translate(locale, keys = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/transmating/i18n.rb', line 14

def translate(locale, keys = {})
  if translated(locale)
    translated(locale).update_attributes keys
  else
    new_translation = Translation.new keys.merge(:locale => locale.to_s)
    translations << new_translation
  end
end

#translated(locale) ⇒ Object



10
11
12
# File 'lib/transmating/i18n.rb', line 10

def translated(locale)
  self.translations.where(:locale => locale.to_s).first
end