Module: NaranyaEcm::Behaviors::Localizable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/naranya_ecm/behaviors/localizable.rb
Instance Method Summary collapse
- #locales ⇒ Object (also: #available_locales)
- #lookup ⇒ Object
Instance Method Details
#locales ⇒ Object Also known as: available_locales
21 22 23 |
# File 'lib/naranya_ecm/behaviors/localizable.rb', line 21 def locales @attributes.keys end |
#lookup ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/naranya_ecm/behaviors/localizable.rb', line 26 def lookup locale = ::I18n.locale if ::I18n.respond_to?(:fallbacks) lookup_result = @attributes[::I18n.fallbacks[locale].map(&:to_s).find{ |loc| @attributes.has_key?(loc) }] else lookup_result = @attributes[locale.to_s] end lookup_result = @attributes.present? ? @attributes.first[1] : nil unless lookup_result.present? lookup_result end |