Created
February 3, 2013 12:36
-
-
Save tkawa/4701610 to your computer and use it in GitHub Desktop.
Railsでlocaleの翻訳が見つからなかったとき、“translation missing”はログに出して、viewにはhumanizeした文字列を出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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