Class/Module Index [+]

Quicksearch

I18n::Backend::Cache

TODO Should the cache be cleared if new translations are stored?

Public Instance Methods

translate(*args) click to toggle source
# File lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb, line 49
def translate(*args)
  I18n.perform_caching? ? fetch(*args) { super } : super
end

Protected Instance Methods

cache_key(*args) click to toggle source
# File lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb, line 65
def cache_key(*args)
  # This assumes that only simple, native Ruby values are passed to I18n.translate.
  # Also, in Ruby < 1.8.7 {}.hash != {}.hash
  # (see http://paulbarry.com/articles/2009/09/14/why-rails-3-will-require-ruby-1-8-7)
  # If args.inspect does not work for you for some reason, patches are very welcome :)
  hash = RUBY_VERSION >= "1.8.7" ? args.hash : args.inspect
  keys = ['i18n', I18n.cache_namespace, hash]
  keys.compact.join('-')
end
fetch(*args, &block) click to toggle source
# File lib/active_support/vendor/i18n-0.4.1/i18n/backend/cache.rb, line 55
def fetch(*args, &block)
  result = I18n.cache_store.fetch(cache_key(*args), &block)
  raise result if result.is_a?(Exception)
  result = result.dup if result.frozen? rescue result
  result
rescue MissingTranslationData => exception
  I18n.cache_store.write(cache_key(*args), exception)
  raise exception
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.