1 # A simple exception handler that behaves like the default exception handler
2 # but additionally logs missing translations to a given log.
4 # Useful for identifying missing translations during testing.
8 # require 'globalize/i18n/missing_translations_log_handler
9 # I18n.missing_translations_logger = RAILS_DEFAULT_LOGGER
10 # I18n.exception_handler = :missing_translations_log_handler
12 # To set up a different log file:
14 # logger = Logger.new("#{RAILS_ROOT}/log/missing_translations.log")
15 # I18n.missing_translations_logger = logger
18 @@missing_translations_logger = nil
21 def missing_translations_logger
22 @@missing_translations_logger ||= begin
23 require 'logger' unless defined?(Logger)
28 def missing_translations_logger=(logger)
29 @@missing_translations_logger = logger
32 def missing_translations_log_handler(exception, locale, key, options)
33 if MissingTranslationData === exception
34 missing_translations_logger.warn(exception.message)
35 return exception.message