Skip to content

Commit

Permalink
Merge pull request #542 from jonian/threadsafe_fallbacks
Browse files Browse the repository at this point in the history
Thread safe fallbacks
  • Loading branch information
radar authored Nov 10, 2020
2 parents df7062f + d024044 commit 4709391
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/i18n/backend/fallbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
#
# I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
module I18n
@@fallbacks = nil

class << self
# Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
def fallbacks
@@fallbacks ||= I18n::Locale::Fallbacks.new
Thread.current[:i18n_fallbacks] ||= I18n::Locale::Fallbacks.new
end

# Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
def fallbacks=(fallbacks)
@@fallbacks = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks
Thread.current[:i18n_fallbacks] = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks
end
end

Expand Down

0 comments on commit 4709391

Please sign in to comment.