From b5e25b13efb0f6ec1fce82cc8b6861a61018d664 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Thu, 21 Jun 2018 23:33:00 +0200 Subject: [PATCH] Fix I18n 0.9.3 compatibility (#1133) 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 | 2 +- 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, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b8897953a0..73dbcdf4f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,7 +12,7 @@ GEM ast (2.4.0) concurrent-ruby (1.0.5) docile (1.3.0) - i18n (0.9.1) + i18n (1.0.1) concurrent-ruby (~> 1.0) jaro_winkler (1.5.1) json (2.1.0) diff --git a/test/test_faker_city.rb b/test/test_faker_city.rb index 4dc6411999..2b5b69f20b 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) # rubocop:disable Lint/InterpolationCheck xy = { @@ -25,8 +25,8 @@ def setup } } # rubocop:enable Lint/InterpolationCheck - 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 df6682e78e..c93e41af6a 100644 --- a/test/test_faker_commerce.rb +++ b/test/test_faker_commerce.rb @@ -40,8 +40,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 be49bd9ced..e18c5900bb 100644 --- a/test/test_faker_street.rb +++ b/test/test_faker_street.rb @@ -22,8 +22,8 @@ def setup } } # rubocop:enable Lint/InterpolationCheck - 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 94e4f0a8c7..fc3e641b2e 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 += %i[xy xz] I18n.backend.store_translations(:xy, locale_without_state) I18n.backend.store_translations(:xz, locale_with_state) - I18n.config.available_locales += %i[xy xz] @tester = Faker::Address end diff --git a/test/test_flexible.rb b/test/test_flexible.rb index 2e2465bf78..a67f804d1b 100644 --- a/test/test_flexible.rb +++ b/test/test_flexible.rb @@ -9,11 +9,11 @@ class Foodie < Base class TestFlexible < Test::Unit::TestCase def setup @old_locales = I18n.config.available_locales + I18n.config.available_locales += %i[xx home kindergarden work] I18n.backend.store_translations(:xx, faker: { chow: { yummie: %i[fudge chocolate caramel], taste: 'delicious' } }) I18n.backend.store_translations(:home, faker: { address: { birthplace: %i[bed hospital airplane] } }) I18n.backend.store_translations(:kindergarden, faker: { name: { girls_name: %i[alice cheryl tatiana] } }) I18n.backend.store_translations(:work, faker: { company: { do_stuff: %i[work work work] } }) - I18n.config.available_locales += %i[xx home kindergarden work] end def teardown