lib/fast_gettext/storage.rb in fast_gettext-1.2.0 vs lib/fast_gettext/storage.rb in fast_gettext-1.3.0

- old
+ new

@@ -134,9 +134,19 @@ return candidate[0..1] if available_locales.include?(candidate[0..1])#available locales include a langauge end return nil#nothing found im sorry :P end + # temporarily switch locale for a block + # FastGettext.with_locale 'xx' { _('cars') } + def with_locale(temp_locale) + current_locale = locale + set_locale temp_locale + yield + ensure + set_locale current_locale + end + #turn off translation if none was defined to disable all resulting errors def silence_errors require 'fast_gettext/translation_repository/base' translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale') end