diff options
| author | hukl <contact@smyck.org> | 2009-02-25 22:37:22 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-25 22:37:22 +0100 |
| commit | f4c73763e5b3d65f3377fb1238a94122a1c272a4 (patch) | |
| tree | 8f6b276f9432e31ae0fe7bffe010e680081a1e0a /vendor/plugins/globalize2/lib/globalize/i18n | |
| parent | 19b07ff63c626f76ad512b95ddbf16cddd2bf855 (diff) | |
updated globalize2
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 | ||
