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 May 20, 2018
1 parent 7ebb2fb commit df6e565
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Expand Up @@ -12,7 +12,7 @@ GEM
concurrent-ruby (1.0.5)
docile (1.3.0)
hirb (0.7.3)
i18n (0.9.1)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
json (2.1.0)
minitest (5.10.3)
Expand Down
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)

# rubocop:disable Lint/InterpolationCheck
xy = {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_commerce.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_faker_street.rb
Expand Up @@ -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
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 += %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

Expand Down
2 changes: 1 addition & 1 deletion test/test_flexible.rb
Expand Up @@ -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
Expand Down

0 comments on commit df6e565

Please sign in to comment.