Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/i18n/backend/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def store_translations(locale, data, options = {})

def lookup(locale, key, scope = [], options = {})
key = normalize_flat_keys(locale, key, scope, options[:separator])
result = Translation.locale(locale).lookup(key).all
result = Translation.locale(locale).lookup(key)

if result.empty?
nil
Expand Down
9 changes: 4 additions & 5 deletions lib/i18n/backend/active_record/translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ class Translation < ::ActiveRecord::Base
TRUTHY_CHAR = "\001"
FALSY_CHAR = "\002"

set_table_name 'translations'
attr_protected :is_proc, :interpolations
self.table_name = 'translations'

serialize :value
serialize :interpolations, Array

class << self
def locale(locale)
scoped(:conditions => { :locale => locale.to_s })
where(:locale => locale.to_s)
end

def lookup(keys, *separator)
Expand All @@ -70,11 +69,11 @@ def lookup(keys, *separator)
end

namespace = "#{keys.last}#{I18n::Backend::Flatten::FLATTEN_SEPARATOR}%"
scoped(:conditions => ["#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace])
where("#{column_name} IN (?) OR #{column_name} LIKE ?", keys, namespace)
end

def available_locales
Translation.find(:all, :select => 'DISTINCT locale').map { |t| t.locale.to_sym }
Translation.distinct(:locale).map { |t| t.locale.to_sym }
end
end

Expand Down