From a8e0a6c8170444e84de092128b7711663fdcfa8c Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sat, 27 Jan 2018 16:49:33 +0100 Subject: [PATCH] Fix I18n 0.9.3 compatibility 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: #1132 Ref: svenfuchs/i18n#391 --- Gemfile.lock | 4 ++-- test/test_faker_city.rb | 4 ++-- test/test_faker_commerce.rb | 2 +- test/test_faker_street.rb | 2 +- test/test_faker_zip_code.rb | 2 +- test/test_flexible.rb | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e300ecf23b..ffc4d64cab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -28,4 +28,4 @@ DEPENDENCIES timecop BUNDLED WITH - 1.16.0 + 1.16.1 diff --git a/test/test_faker_city.rb b/test/test_faker_city.rb index a27a2ff19a..558a8de73e 100644 --- a/test/test_faker_city.rb +++ b/test/test_faker_city.rb @@ -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 => { @@ -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 diff --git a/test/test_faker_commerce.rb b/test/test_faker_commerce.rb index a33e81f16d..7f37a508e7 100644 --- a/test/test_faker_commerce.rb +++ b/test/test_faker_commerce.rb @@ -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 diff --git a/test/test_faker_street.rb b/test/test_faker_street.rb index 7866df8f23..ffcbded9de 100644 --- a/test/test_faker_street.rb +++ b/test/test_faker_street.rb @@ -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 diff --git a/test/test_faker_zip_code.rb b/test/test_faker_zip_code.rb index b29f132102..a70f50dfd7 100644 --- a/test/test_faker_zip_code.rb +++ b/test/test_faker_zip_code.rb @@ -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 diff --git a/test/test_flexible.rb b/test/test_flexible.rb index e498967ef3..7d7a8f3c70 100644 --- a/test/test_flexible.rb +++ b/test/test_flexible.rb @@ -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