google-code-export / globalite

Automatically exported from code.google.com/p/globalite
1 stars 0 forks source link

with_locale('fr-FR') do ... end #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I need a temporary locale. I noticed the locale option for
Globalite::L10n.localize(), but this seems like a better solution:

class Object
  def with_locale(locale, &block)
    original_locale = Locale.code
    Locale.set_code(locale)
    returning block.call do
      Locale.set_code(original_locale)
    end
  end
end

Original issue reported on code.google.com by cainl...@gmail.com on 19 Dec 2007 at 7:18