diff options
Diffstat (limited to 'vendor/plugins/globalize2/lib/globalize/i18n')
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb b/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb new file mode 100644 index 00000000..e32be280 --- /dev/null +++ b/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # A simple exception handler that behaves like the default exception handler | ||
| 2 | # but also raises on missing translations. | ||
| 3 | # | ||
| 4 | # Useful for identifying missing translations during testing. | ||
| 5 | # | ||
| 6 | # E.g. | ||
| 7 | # | ||
| 8 | # require 'globalize/i18n/missing_translations_raise_handler | ||
| 9 | # I18n.exception_handler = :missing_translations_raise_handler | ||
| 10 | module I18n | ||
| 11 | class << self | ||
| 12 | def missing_translations_raise_handler(exception, locale, key, options) | ||
| 13 | raise exception | ||
| 14 | end | ||
| 15 | end | ||
| 16 | |||
| 17 | # self.exception_handler = :missing_translations_raise_handler | ||
| 18 | end | ||
| 19 | |||
| 20 | I18n.exception_handler = :missing_translations_raise_handler | ||
| 21 | |||
| 22 | ActionView::Helpers::TranslationHelper.module_eval do | ||
| 23 | def translate(key, options = {}) | ||
| 24 | I18n.translate(key, options) | ||
| 25 | end | ||
| 26 | alias :t :translate | ||
| 27 | end | ||
