class I18n::Backend::ActiveRecord::Translation
Constants
- FALSY_CHAR
- TRUTHY_CHAR
Public Class Methods
available_locales()
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 75 def available_locales Translation.distinct.pluck(:locale).map(&:to_sym) end
locale(locale)
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 58 def locale(locale) where(:locale => locale.to_s) end
lookup(keys, *separator)
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 62 def lookup(keys, *separator) column_name = connection.quote_column_name('key') keys = Array(keys).map! { |key| key.to_s } unless separator.empty? warn "[DEPRECATION] Giving a separator to Translation.lookup is deprecated. " << "You can change the internal separator by overwriting FLATTEN_SEPARATOR." end namespace = "#{keys.last}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%" where("#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace) end
Public Instance Methods
interpolates?(key)
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 80 def interpolates?(key) self.interpolations.include?(key) if self.interpolations end
value()
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 84 def value value = read_attribute(:value) if is_proc Kernel.eval(value) elsif value == FALSY_CHAR false elsif value == TRUTHY_CHAR true else value end end
value=(value)
click to toggle source
# File lib/i18n/backend/active_record/translation.rb, line 97 def value=(value) if value === false value = FALSY_CHAR elsif value === true value = TRUTHY_CHAR end write_attribute(:value, value) end