diff options
| author | hukl <contact@smyck.org> | 2010-01-14 22:21:43 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2010-01-14 22:21:43 +0100 |
| commit | 57d1382013c85a7b11ac8ce5e683f6006b12b328 (patch) | |
| tree | 19646c4fa5952fa1cf0a2c874952affa346373f1 /vendor/plugins/globalize2/lib/globalize/i18n | |
| parent | 1b86bf5f2e35d1820bfa32d979bcc2d9ff9a9a8e (diff) | |
Updated globalize2 to latest version. Modified existing code accoringly
Diffstat (limited to 'vendor/plugins/globalize2/lib/globalize/i18n')
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_log_handler.rb | 41 | ||||
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb | 27 |
2 files changed, 0 insertions, 68 deletions
diff --git a/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_log_handler.rb b/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_log_handler.rb deleted file mode 100644 index 3f06ac24..00000000 --- a/vendor/plugins/globalize2/lib/globalize/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 \ No newline at end of file | ||
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 deleted file mode 100644 index e32be280..00000000 --- a/vendor/plugins/globalize2/lib/globalize/i18n/missing_translations_raise_handler.rb +++ /dev/null | |||
| @@ -1,27 +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 | |||
| 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 | ||
