Module: AttrTranslatable::Translation

Defined in:
lib/attr_translatable/translation.rb

Instance Method Summary collapse

Instance Method Details

#t(attr, lang) ⇒ Object



14
15
16
# File 'lib/attr_translatable/translation.rb', line 14

def t(attr, lang)
  internal_translate(attr, lang)
end

#translate(attr, lang) ⇒ Object



10
11
12
# File 'lib/attr_translatable/translation.rb', line 10

def translate(attr, lang)
  internal_translate(attr, lang)
end

#translated_all?(lang) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/attr_translatable/translation.rb', line 18

def translated_all?(lang)
  lang = lang.to_s
  self.class.translatable_attrs.all? do |attr|
    AttrTranslation.exists? :attr => attr, :lang => lang, :model_id => self.id, :model_type => self.class.name
  end
end

#update_translation(attr, lang, translation) ⇒ Object



6
7
8
# File 'lib/attr_translatable/translation.rb', line 6

def update_translation(attr, lang, translation)
  new_translation(attr, lang, translation).save
end