Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread issue when calling translate with Fallbacks #369

Closed
bcornellCC opened this issue May 25, 2017 · 0 comments
Closed

Thread issue when calling translate with Fallbacks #369

bcornellCC opened this issue May 25, 2017 · 0 comments

Comments

@bcornellCC
Copy link

@bcornellCC bcornellCC commented May 25, 2017

What I tried to do

I ran a rails application in a threaded environment with calls to I18n.t where there is no translation in my locale but there is a translation in a fallback locale

What I expected to happen

I expected I18n.t to return the translation string from the fallback locale

What actually happened

Occasionally and unpredictably I received a missing translation error

Versions of i18n, rails, and anything else you think is necessary

i18n version 0.8.1. I was previously using version 0.7.0 and did not experience this issue.


This code reproduces the issue fairly reliably with i18n 0.8.1 but works properly with 0.7.0

require 'i18n'
class Backend < I18n::Backend::Simple
  include I18n::Backend::Fallbacks
end
I18n.backend = Backend.new
I18n.backend.store_translations(:en, {'foo' => 'bar'})
I18n.backend.store_translations(:de , { 'baz' => 'buz'})

threads = []
100.times do
  threads << Thread.new do
    100.times do
      I18n.t('foo', raise: true, locale: :de)
    end
  end
end
threads.each &:join
@radar radar closed this in abd1ae0 Jul 6, 2017
radar added a commit that referenced this issue Jul 6, 2017
Fixes #369 thread issue when calling translate with fallbacks
radar added a commit that referenced this issue Oct 1, 2017
* master: (45 commits)
  Add regression test for #378
  Bump to 0.8.6
  Add fallback_in_progress to RESERVED_KEYS list
  Bump to 0.8.5
  Fixes #369 thread issue when calling translate with fallbacks
  Remove gemfiles/Gemfile.*.lock from the repo
  Improve error message for missing pluralization key
  Bump to 0.8.4
  Revert "Don't allow nil to be submitted as a key to i18n.translate()"
  Bump to 0.8.3
  Update Changelog
  Handle false as a key correctly
  Bump Gemfiles
  Bump to 0.8.2
  Add Gemfile.lock for each Rails version
  Bump to 0.8.1
  Fix transliteration to default replacement char
  Docs: Add 0.8.0 to changelog
  No need to skip ruby 2.4+ x rails 4 now
  CI against newest stable rubies for each minor version
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant