Module: Internationalize::Model
Overview
Mixin for ActiveRecord models to enable internationalization
Constant Summary collapse
- VALID_DIRECTIONS =
["ASC", "DESC"].freeze
Instance Method Summary collapse
-
#translated?(attr, locale) ⇒ Boolean
Check if a translation exists for a specific locale.
-
#translated_locales(attr) ⇒ Object
Returns all locales that have a translation for an attribute.
Instance Method Details
#translated?(attr, locale) ⇒ Boolean
Check if a translation exists for a specific locale
437 438 439 440 |
# File 'lib/internationalize/model.rb', line 437 def translated?(attr, locale) translations = read_attribute("#{attr}_translations") translations[locale.to_s].present? end |
#translated_locales(attr) ⇒ Object
Returns all locales that have a translation for an attribute
443 444 445 446 |
# File 'lib/internationalize/model.rb', line 443 def translated_locales(attr) translations = read_attribute("#{attr}_translations") translations.filter_map { |k, v| k.to_sym if v.present? } end |