Skip to content

Commit

Permalink
adding nested_hash lookups to the cache as appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
William Lorentson committed Dec 1, 2009
1 parent 49ee522 commit e5769ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/i18n_backend_database/database.rb
Expand Up @@ -71,7 +71,11 @@ def translate(locale, key, options = {})
#We need to escape % and \. Rails will handle the rest.
escaped_key = key.to_s.gsub('\\', '\\\\\\\\').gsub(/%/, '\%')
children = @locale.translations.find :all, :conditions => ["raw_key like ?", "#{escaped_key}.%"]
return hashify_record_array(key.to_s, children) if children.size > 0
if children.size > 0
entry = hashify_record_array(key.to_s, children)
@cache_store.write(Translation.ck(@locale, key), entry) unless cache_lookup == true
return entry
end
end

# we check the database before creating a translation as we can have translations with nil values
Expand Down

0 comments on commit e5769ae

Please sign in to comment.