Class: I18n::Backend::Weeler::Translation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- I18n::Backend::Weeler::Translation
- Defined in:
- lib/i18n/backend/weeler/translation.rb
Constant Summary collapse
- TRUTHY_CHAR =
"\001"
- FALSY_CHAR =
"\002"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.groups ⇒ Object
82 83 84 85 86 87 88 89 90 |
# 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) ⇒ Object
64 65 66 |
# File 'lib/i18n/backend/weeler/translation.rb', line 64 def locale(locale) where(:locale => locale.to_s) end |
.lookup(keys, *separator) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# 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 |
Instance Method Details
#interpolates?(key) ⇒ Boolean
93 94 95 |
# File 'lib/i18n/backend/weeler/translation.rb', line 93 def interpolates?(key) self.interpolations.include?(key) if self.interpolations end |
#value ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 |
# 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) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# 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 |