Skip to content

Commit

Permalink
Fix I18n 0.9.3 compatibility
Browse files Browse the repository at this point in the history
Starting from version 0.9.3, I18n doesn't store translations for locales
not set as available.

This change set locales as available before storing translations.

Fix: faker-ruby#1132

Ref: ruby-i18n/i18n#391
  • Loading branch information
tagliala committed Jan 27, 2018
1 parent 679fd50 commit a8e0a6c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -8,7 +8,7 @@ GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.0.5)
i18n (0.9.1)
i18n (0.9.3)
concurrent-ruby (~> 1.0)
minitest (5.10.3)
power_assert (1.1.1)
Expand All @@ -28,4 +28,4 @@ DEPENDENCIES
timecop

BUNDLED WITH
1.16.0
1.16.1
4 changes: 2 additions & 2 deletions test/test_faker_city.rb
Expand Up @@ -9,8 +9,8 @@ def setup
:address => {:city_prefix => ['west'], :city_suffix => ['burg']}
}
}
I18n.backend.store_translations(:xx, xx)
I18n.config.available_locales += [ :xx ]
I18n.backend.store_translations(:xx, xx)

xy = {
:faker => {
Expand All @@ -23,8 +23,8 @@ def setup
}
}
}
I18n.backend.store_translations(:xy, xy)
I18n.config.available_locales += [ :xy ]
I18n.backend.store_translations(:xy, xy)
end

def teardown
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_commerce.rb
Expand Up @@ -41,8 +41,8 @@ def test_department_should_accept_localized_separator
}
}

I18n.backend.store_translations(:xy, data)
I18n.config.available_locales += [ :xy ]
I18n.backend.store_translations(:xy, data)
I18n.with_locale(:xy) do
assert_match ' + ', @tester.department(2, true)
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_street.rb
Expand Up @@ -20,8 +20,8 @@ def setup
}
}
}
I18n.backend.store_translations(:shire, shire)
I18n.config.available_locales += [ :shire ]
I18n.backend.store_translations(:shire, shire)
end

def teardown
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_zip_code.rb
Expand Up @@ -26,9 +26,9 @@ def setup
}
}

I18n.config.available_locales += [:xy, :xz]
I18n.backend.store_translations(:xy, locale_without_state)
I18n.backend.store_translations(:xz, locale_with_state)
I18n.config.available_locales += [:xy, :xz]
@tester = Faker::Address
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_flexible.rb
Expand Up @@ -10,11 +10,11 @@ class TestFlexible < Test::Unit::TestCase

def setup
@old_locales = I18n.config.available_locales
I18n.config.available_locales += [ :xx, :home, :kindergarden, :work ]
I18n.backend.store_translations(:xx, :faker => {:chow => {:yummie => [:fudge, :chocolate, :caramel], :taste => "delicious"}})
I18n.backend.store_translations(:home, :faker => {:address => {:birthplace => [:bed, :hospital, :airplane]}})
I18n.backend.store_translations(:kindergarden, :faker => {:name => {:girls_name => [:alice, :cheryl, :tatiana]}})
I18n.backend.store_translations(:work, :faker => {:company => {:do_stuff => [:work, :work, :work]}})
I18n.config.available_locales += [ :xx, :home, :kindergarden, :work ]
end

def teardown
Expand Down

0 comments on commit a8e0a6c

Please sign in to comment.