Module: ZLocalize::Translatable::TranslatedAttributesSerializer::InstanceMethods

Defined in:
lib/zlocalize/rails/translated_attributes_serializer.rb

Instance Method Summary collapse

Instance Method Details

#read_translated_attribute(attr_name, locale) ⇒ Object Also known as: translate



38
39
40
41
# File 'lib/zlocalize/rails/translated_attributes_serializer.rb', line 38

def read_translated_attribute(attr_name,locale)
  s = self.translated_attributes[locale]
  s.is_a?(Hash) ? s[attr_name] : nil
end

#translationsObject



45
46
47
# File 'lib/zlocalize/rails/translated_attributes_serializer.rb', line 45

def translations
  translated_attributes
end

#translations=(locales) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/zlocalize/rails/translated_attributes_serializer.rb', line 49

def translations=(locales)
  locales.each do |locale,terms|
    self.translated_attributes[locale] ||= HashWithIndifferentAccess.new
    terms.each do |name,value|
      self.translated_attributes[locale][name] = value
    end
  end
end