Skip to content

Commit

Permalink
Globalize now assigns locale like I18n by converting it to a symbol
Browse files Browse the repository at this point in the history
* this makes sure both libs use the truly same locale and not :en <=> 'en'
* otherwise I18n.locale == Globalize.locale returns false
  • Loading branch information
Marc Remolt committed May 11, 2011
1 parent f44d006 commit 63d4dc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/globalize.rb
Expand Up @@ -44,7 +44,7 @@ def read_locale
end

def set_locale(locale)
Thread.current[:globalize_locale] = locale
Thread.current[:globalize_locale] = locale.to_sym rescue nil
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions test/globalize3/locale_test.rb
Expand Up @@ -30,6 +30,20 @@ class LocaleTest < Test::Unit::TestCase
assert_equal :es, Globalize.locale
end

test "Globalize locale setting with strings" do
I18n.locale = 'de'
Globalize.locale = 'de'
assert_equal I18n.locale, Globalize.locale

I18n.locale = 'de'
Globalize.locale = :de
assert_equal I18n.locale, Globalize.locale

I18n.locale = :de
Globalize.locale = 'de'
assert_equal I18n.locale, Globalize.locale
end

test 'with_locale temporarily sets the given locale and yields the block' do
assert_equal :en, Globalize.locale
Globalize.with_locale :de do |locale|
Expand Down

0 comments on commit 63d4dc7

Please sign in to comment.