Module: SerialTranslator
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/serial_translator.rb,
lib/serial_translator/version.rb,
lib/serial_translator/serial_translator_length_validator.rb,
lib/serial_translator/serial_translator_presence_validator.rb
Defined Under Namespace
Modules: ClassMethods
Classes: InvalidLocaleError, SerialTranslatorLengthValidator, SerialTranslatorPresenceValidator, TranslationType
Constant Summary
collapse
- VERSION =
"2.0.5".freeze
Instance Method Summary
collapse
Instance Method Details
#current_translation_locale ⇒ Object
90
91
92
|
# File 'lib/serial_translator.rb', line 90
def current_translation_locale
(@current_translation_locale || I18n.locale).to_sym
end
|
#translated_into?(locale) ⇒ Boolean
111
112
113
|
# File 'lib/serial_translator.rb', line 111
def translated_into?(locale)
translated_locales.include?(locale.to_sym)
end
|
#translated_locales ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/serial_translator.rb', line 98
def translated_locales
result = []
self.class.serial_translator_attributes.each do |attribute|
translations = translations_for(attribute).select { |_, value| value.present? }
result += translations.keys
end
result.uniq
end
|
#translation_fallback? ⇒ Boolean
94
95
96
|
# File 'lib/serial_translator.rb', line 94
def translation_fallback?
@translation_fallback != false
end
|
#translations_for(attribute) ⇒ Object
107
108
109
|
# File 'lib/serial_translator.rb', line 107
def translations_for(attribute)
__send__(:"#{attribute}_translations") || {}
end
|