forked from joshmh/globalize2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing_translations_raise_handler
- Loading branch information
Joshua Harvey
committed
Feb 11, 2009
1 parent
3cb9423
commit 47e9c6e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 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 | ||
|
||
module I18n | ||
class << self | ||
def missing_translations_raise_handler(exception, locale, key, options) | ||
raise exception | ||
end | ||
end | ||
|
||
# self.exception_handler = :missing_translations_raise_handler | ||
end | ||
|
||
I18n.exception_handler = :missing_translations_raise_handler | ||
|
||
ActionView::Helpers::TranslationHelper.module_eval do | ||
def translate(key, options = {}) | ||
I18n.translate(key, options) | ||
end | ||
alias :t :translate | ||
end |