File: i18n_hacks.rb

package info (click to toggle)
ruby-gettext-i18n-rails 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: ruby: 515; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
I18n::Config # autoload

module I18n
  class Config
    def locale
      FastGettext.locale.gsub("_","-").to_sym
    end

     def locale=(new_locale)
      FastGettext.locale=(new_locale)
    end
  end

  # backport I18n.with_locale if it does not exist
  # Executes block with given I18n.locale set.
  def self.with_locale(tmp_locale = nil)
    if tmp_locale
      current_locale = self.locale
      self.locale = tmp_locale
    end
    yield
  ensure
    self.locale = current_locale if tmp_locale
  end unless defined? I18n.with_locale
end