Class: I18n::Backend::Sequel::Translation

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_backend_sequel/translation.rb

Constant Summary collapse

TRUTHY_CHAR =
"\001"
FALSY_CHAR =
"\002"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_localesObject



76
77
78
# File 'lib/i18n_backend_sequel/translation.rb', line 76

def available_locales
  Translation.distinct.select(:locale).all.map { |t| t.locale.to_sym }
end

Instance Method Details

#interpolates?(key) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/i18n_backend_sequel/translation.rb', line 81

def interpolates?(key)
  self.interpolations.include?(key) if self.interpolations
end

#valueObject



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/i18n_backend_sequel/translation.rb', line 85

def value
  value = self[:value]
  if is_proc
    Kernel.eval(value)
  elsif value == FALSY_CHAR
    false
  elsif value == TRUTHY_CHAR
    true
  else
    value
  end
end

#value=(value) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/i18n_backend_sequel/translation.rb', line 98

def value=(value)
  if value === false
    value = FALSY_CHAR
  elsif value === true
    value = TRUTHY_CHAR
  end

  write_attribute(:value, value)
end