module I18n::Backend::Fallback::Implementation
Public Instance Methods
translate(locale, key, default_options = {})
click to toggle source
add the simplest possible fallback to the I18n.default_locale for missing translations by using super() with I18n.default_locale for a second lookup
Calls superclass method
# File lib/exvo_globalize/backend/fallback.rb, line 8 def translate(locale, key, default_options = {}) if defined?(I18n::MissingTranslation) # i18n gem >= 0.6.0 (so we need to CATCH the exception) result = catch(:exception) do super(locale, key, default_options) end if result.is_a?(MissingTranslation) super(I18n.default_locale, key, default_options) else result end elsif defined?(I18n::MissingTranslationData) # i18n gem ~> 0.5.0 (so we need to RESCUE from the exception) begin super(locale, key, default_options) rescue I18n::MissingTranslationData super(I18n.default_locale, key, default_options) end else fail "Incompatible i18n gem version detected. OMG sky is falling..." end end