Skip to content

Instantly share code, notes, and snippets.

@FUT
Created September 20, 2012 08:17
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 FUT/3754634 to your computer and use it in GitHub Desktop.
Save FUT/3754634 to your computer and use it in GitHub Desktop.
I18n translation debugging. Usage: SHOW_TR=true rails s
require 'i18n'
if (Rails.env.development? || Rails.env.test?) && ENV['SHOW_TR']
module I18n
class << self
def translate_with_debug(*args)
translation = translate_without_debug(*args)
puts "[\e[32mTranslate\e[0m] #{args.inspect}\t [\e[31mResult\e[0m] #{translation}"
translation
end
alias_method_chain :translate, :debug
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment