Module: Worldwide::Cldr::FiberStorage

Defined in:
lib/worldwide/cldr.rb

Overview

i18n 1.15 keeps the active config and fallbacks in Fiber storage on Ruby 3.2+ and in thread-local storage otherwise. We must write the same slots i18n reads back, so a Thread.current write is not silently ignored on Ruby 3.2+. These strategies mirror i18n's own storage; the one matching the runtime is selected once into STORAGE.

Class Method Summary collapse

Class Method Details

.configObject



21
22
23
# File 'lib/worldwide/cldr.rb', line 21

def config
  Fiber[:i18n_config]
end

.config=(value) ⇒ Object



25
26
27
28
# File 'lib/worldwide/cldr.rb', line 25

def config=(value)
  Fiber[:i18n_config] = value
  value.owner = Fiber.current if value.respond_to?(:owner=) && !value.frozen?
end

.fallbacksObject



30
31
32
# File 'lib/worldwide/cldr.rb', line 30

def fallbacks
  Fiber[:i18n_fallbacks]
end

.fallbacks=(value) ⇒ Object



34
35
36
# File 'lib/worldwide/cldr.rb', line 34

def fallbacks=(value)
  Fiber[:i18n_fallbacks] = value
end