class I18n::Backend::Weeler::Translation

Constants

FALSY_CHAR
TRUTHY_CHAR

Public Class Methods

groups() click to toggle source
# File lib/i18n/backend/weeler/translation.rb, line 82
def groups
  groups_records = Translation.select("key")

  ::Weeler.excluded_i18n_groups.each do |key|
    groups_records = groups_records.except_key(key)
  end
  groups_records = groups_records.order("key")
  groups_records.map{ |t| t.key.split(".")[0] }.uniq{ |t| t}
end
locale(locale) click to toggle source
# File lib/i18n/backend/weeler/translation.rb, line 64
def locale(locale)
  where(:locale => locale.to_s)
end
lookup(keys, *separator) click to toggle source
# File lib/i18n/backend/weeler/translation.rb, line 68
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/weeler/translation.rb, line 93
def interpolates?(key)
  self.interpolations.include?(key) if self.interpolations
end
value() click to toggle source
# File lib/i18n/backend/weeler/translation.rb, line 97
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/weeler/translation.rb, line 110
def value=(value)
  if value === false
    value = FALSY_CHAR
  elsif value === true
    value = TRUTHY_CHAR
  end

  write_attribute(:value, value)
end