diff options
Diffstat (limited to 'vendor/plugins/globalize2/lib/i18n')
| -rw-r--r-- | vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb | 41 | ||||
| -rw-r--r-- | vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb | 25 |
2 files changed, 0 insertions, 66 deletions
diff --git a/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb b/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb deleted file mode 100644 index 24c10890..00000000 --- a/vendor/plugins/globalize2/lib/i18n/missing_translations_log_handler.rb +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | # A simple exception handler that behaves like the default exception handler | ||
| 2 | # but additionally logs missing translations to a given log. | ||
| 3 | # | ||
| 4 | # Useful for identifying missing translations during testing. | ||
| 5 | # | ||
| 6 | # E.g. | ||
| 7 | # | ||
| 8 | # require 'globalize/i18n/missing_translations_log_handler' | ||
| 9 | # I18n.missing_translations_logger = RAILS_DEFAULT_LOGGER | ||
| 10 | # I18n.exception_handler = :missing_translations_log_handler | ||
| 11 | # | ||
| 12 | # To set up a different log file: | ||
| 13 | # | ||
| 14 | # logger = Logger.new("#{RAILS_ROOT}/log/missing_translations.log") | ||
| 15 | # I18n.missing_translations_logger = logger | ||
| 16 | |||
| 17 | module I18n | ||
| 18 | @@missing_translations_logger = nil | ||
| 19 | |||
| 20 | class << self | ||
| 21 | def missing_translations_logger | ||
| 22 | @@missing_translations_logger ||= begin | ||
| 23 | require 'logger' unless defined?(Logger) | ||
| 24 | Logger.new(STDOUT) | ||
| 25 | end | ||
| 26 | end | ||
| 27 | |||
| 28 | def missing_translations_logger=(logger) | ||
| 29 | @@missing_translations_logger = logger | ||
| 30 | end | ||
| 31 | |||
| 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 | ||
| 36 | else | ||
| 37 | raise exception | ||
| 38 | end | ||
| 39 | end | ||
| 40 | end | ||
| 41 | end | ||
diff --git a/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb b/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb deleted file mode 100644 index 18237b15..00000000 --- a/vendor/plugins/globalize2/lib/i18n/missing_translations_raise_handler.rb +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 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 | end | ||
| 17 | |||
| 18 | I18n.exception_handler = :missing_translations_raise_handler | ||
| 19 | |||
| 20 | ActionView::Helpers::TranslationHelper.module_eval do | ||
| 21 | def translate(key, options = {}) | ||
| 22 | I18n.translate(key, options) | ||
| 23 | end | ||
| 24 | alias :t :translate | ||
| 25 | end | ||
