Skip to content

Commit

Permalink
store fallbacks in Thread.current and fetch with @@fallbacks as default
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Jan 4, 2021
1 parent e264dca commit 1f2e328
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/i18n/backend/fallbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ class << self
# Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
def fallbacks
@@fallbacks ||= I18n::Locale::Fallbacks.new
Thread.current.fetch(:i18n_fallbacks, @@fallbacks)
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
end
end

Expand Down

0 comments on commit 1f2e328

Please sign in to comment.