Module: ZLocalize::Translatable::TranslatedAttributesSerializer::InstanceMethods
- Defined in:
- lib/zlocalize/rails/translated_attributes_serializer.rb
Instance Method Summary collapse
- #read_translated_attribute(attr_name, locale) ⇒ Object (also: #translate)
- #translations=(locales) ⇒ Object
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 |
#translations=(locales) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/zlocalize/rails/translated_attributes_serializer.rb', line 45 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 |