Module: I18n
- Defined in:
- lib/i18n/missing_translations_log_handler.rb,
lib/i18n/missing_translations_raise_handler.rb
Overview
A simple exception handler that behaves like the default exception handler but also raises on missing translations.
Useful for identifying missing translations during testing.
E.g.
require 'globalize/i18n/missing_translations_raise_handler'
I18n.exception_handler = :missing_translations_raise_handler
Constant Summary collapse
- @@missing_translations_logger =
nil
Class Method Summary collapse
- .missing_translations_log_handler(exception, locale, key, options) ⇒ Object
- .missing_translations_logger ⇒ Object
- .missing_translations_logger=(logger) ⇒ Object
- .missing_translations_raise_handler(exception, locale, key, options) ⇒ Object
Class Method Details
.missing_translations_log_handler(exception, locale, key, options) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/i18n/missing_translations_log_handler.rb', line 32 def missing_translations_log_handler(exception, locale, key, ) if MissingTranslationData === exception missing_translations_logger.warn(exception.) return exception. else raise exception end end |
.missing_translations_logger ⇒ Object
21 22 23 24 25 26 |
# File 'lib/i18n/missing_translations_log_handler.rb', line 21 def missing_translations_logger @@missing_translations_logger ||= begin require 'logger' unless defined?(Logger) Logger.new(STDOUT) end end |
.missing_translations_logger=(logger) ⇒ Object
28 29 30 |
# File 'lib/i18n/missing_translations_log_handler.rb', line 28 def missing_translations_logger=(logger) @@missing_translations_logger = logger end |
.missing_translations_raise_handler(exception, locale, key, options) ⇒ Object
12 13 14 |
# File 'lib/i18n/missing_translations_raise_handler.rb', line 12 def missing_translations_raise_handler(exception, locale, key, ) raise exception end |