Skip to content

Commit

Permalink
Explicitly access the global Locale method in case there's an I18n::L…
Browse files Browse the repository at this point in the history
…ocale module.
  • Loading branch information
pupeno authored and Masao Mutoh committed Jun 15, 2010
1 parent ea3dfae commit 2bad606
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/locale_rails/i18n.rb
Expand Up @@ -13,35 +13,35 @@ module I18n

# Gets the supported locales.
def supported_locales
Locale.app_language_tags
::Locale.app_language_tags
end

# Sets the supported locales.
# I18n.set_supported_locales("ja-JP", "ko-KR", ...)
def set_supported_locales(*tags)
Locale.set_app_language_tags(*tags)
::Locale.set_app_language_tags(*tags)
end

# Sets the supported locales as an Array.
# I18n.supported_locales = ["ja-JP", "ko-KR", ...]
def supported_locales=(tags)
Locale.set_app_language_tags(*tags)
::Locale.set_app_language_tags(*tags)
end

# Sets the locale.
# Sets the ::Locale.
# I18n.locale = "ja-JP"
def locale=(tag)
Locale.clear
::Locale.clear
tag = Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
Locale.current = tag
Thread.current[:locale] = Locale.candidates(:type => :rfc)[0]
::Locale.current = tag
Thread.current[:locale] = ::Locale.candidates(:type => :rfc)[0]
end

# Sets the default locale.
# Sets the default ::Locale.
# I18n.default_locale = "ja"
def default_locale=(tag)
tag = Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
Locale.default = tag
::Locale.default = tag
@@default_locale = tag
end

Expand All @@ -50,7 +50,7 @@ class << self
# MissingTranslationData is overrided to fallback messages in candidate locales.
def locale_rails_exception_handler(exception, locale, key, options) #:nodoc:
ret = nil
Locale.candidates(:type => :rfc).each do |loc|
::Locale.candidates(:type => :rfc).each do |loc|
begin
ret = backend.translate(loc, key, options)
break
Expand Down

0 comments on commit 2bad606

Please sign in to comment.