Skip to content

Instantly share code, notes, and snippets.

@tkawa
Created February 3, 2013 12:36
Show Gist options
  • Save tkawa/4701610 to your computer and use it in GitHub Desktop.
Save tkawa/4701610 to your computer and use it in GitHub Desktop.
Railsでlocaleの翻訳が見つからなかったとき、“translation missing”はログに出して、viewにはhumanizeした文字列を出す
# config/initializers/i18n_exception_handler.rb
I18n.exception_handler = ->(exception, locale, key, options) do
if exception.is_a?(I18n::MissingTranslation)
Rails.logger.warn exception.message if Rails.env.development?
key.to_s.split('.').last.humanize
else
raise exception
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment