Skip to content

Instantly share code, notes, and snippets.

@tomeduarte
Created March 15, 2013 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomeduarte/5174151 to your computer and use it in GitHub Desktop.
Save tomeduarte/5174151 to your computer and use it in GitHub Desktop.
A Ruby on Rails initializer which binds I18n.translate and logs every lookup to logs/i18n_registry.log. Tested on Rails 3.
# adapted from: http://stackoverflow.com/a/10211540/514700
module I18n
module Registry
protected
def lookup(locale, key, scope = [], options = {})
@log ||= Logger.new(File.join(Rails.root, 'log', 'i18n_registry.log'))
@log.info "i18n lookup - key: #{key} | locale: #{locale} | scope: #{scope}"
super
end
end
end
I18n::Backend::Simple.send :include, I18n::Registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment