i18n 1.15.1 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i18n/backend/fallbacks.rb +10 -2
- data/lib/i18n/middleware.rb +5 -1
- data/lib/i18n/version.rb +1 -1
- data/lib/i18n.rb +22 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 600a63b2ec049818152fff57053db49142c9f51ea58da7d6c3200011974a5707
|
|
4
|
+
data.tar.gz: a7ef9def35a09233a6b80f1aee94052d18db1220f5dcf6df59053f5f30d54efa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b8196a163065458e0d13d37ed09817cfef09848e24eb061537467c9cc06f75b50619f2cd179890b904d819fb5ace61c353dce51bd673ec116398329777e38ba
|
|
7
|
+
data.tar.gz: b3d96b130b6d089571bd2480a9f4a9675e423d39d5b82c55fea56f0e0e553a85a63a80c3f494f9a450d356cac718494e04ce1a3add5efea0ccfc3f8f01581b97
|
data/README.md
CHANGED
|
@@ -19,7 +19,7 @@ We support Rails versions from 6.0 and up.
|
|
|
19
19
|
|
|
20
20
|
### Ruby (without Rails)
|
|
21
21
|
|
|
22
|
-
We support Ruby versions from 3.
|
|
22
|
+
We support Ruby versions from 3.1 and up.
|
|
23
23
|
|
|
24
24
|
If you want to use this library without Rails, you can simply add `i18n` to your `Gemfile`:
|
|
25
25
|
|
|
@@ -16,13 +16,21 @@ module I18n
|
|
|
16
16
|
# Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
|
|
17
17
|
def fallbacks
|
|
18
18
|
@@fallbacks ||= I18n::Locale::Fallbacks.new
|
|
19
|
-
Fiber[
|
|
19
|
+
if Fiber.respond_to?(:[])
|
|
20
|
+
Fiber[:i18n_fallbacks] || @@fallbacks
|
|
21
|
+
else
|
|
22
|
+
Thread.current[:i18n_fallbacks] || @@fallbacks
|
|
23
|
+
end
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
# Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
|
|
23
27
|
def fallbacks=(fallbacks)
|
|
24
28
|
@@fallbacks = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks
|
|
25
|
-
Fiber[
|
|
29
|
+
if Fiber.respond_to?(:[])
|
|
30
|
+
Fiber[:i18n_fallbacks] = @@fallbacks
|
|
31
|
+
else
|
|
32
|
+
Thread.current[:i18n_fallbacks] = @@fallbacks
|
|
33
|
+
end
|
|
26
34
|
end
|
|
27
35
|
end
|
|
28
36
|
|
data/lib/i18n/middleware.rb
CHANGED
|
@@ -10,7 +10,11 @@ module I18n
|
|
|
10
10
|
def call(env)
|
|
11
11
|
@app.call(env)
|
|
12
12
|
ensure
|
|
13
|
-
Fiber[
|
|
13
|
+
if Fiber.respond_to?(:[])
|
|
14
|
+
Fiber[:i18n_config] = I18n::Config.new
|
|
15
|
+
else
|
|
16
|
+
Thread.current.thread_variable_set(:i18n_config, I18n::Config.new)
|
|
17
|
+
end
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
end
|
data/lib/i18n/version.rb
CHANGED
data/lib/i18n.rb
CHANGED
|
@@ -55,13 +55,18 @@ module I18n
|
|
|
55
55
|
module Base
|
|
56
56
|
# Gets I18n configuration object.
|
|
57
57
|
def config
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
current
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
if Fiber.respond_to?(:[])
|
|
59
|
+
current = Fiber[:i18n_config] || self.config = I18n::Config.new
|
|
60
|
+
if current.respond_to?(:owned_by?) && !current.owned_by?(Fiber.current)
|
|
61
|
+
current = current.dup
|
|
62
|
+
Fiber[:i18n_config] = current
|
|
63
|
+
end
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
current
|
|
66
|
+
else
|
|
67
|
+
Thread.current.thread_variable_get(:i18n_config) ||
|
|
68
|
+
Thread.current.thread_variable_set(:i18n_config, I18n::Config.new)
|
|
69
|
+
end
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
# Gets a mutable I18n configuration object.
|
|
@@ -70,14 +75,22 @@ module I18n
|
|
|
70
75
|
return current unless current.frozen?
|
|
71
76
|
|
|
72
77
|
current = current.dup
|
|
73
|
-
Fiber[
|
|
78
|
+
if Fiber.respond_to?(:[])
|
|
79
|
+
Fiber[:i18n_config] = current
|
|
80
|
+
else
|
|
81
|
+
Thread.current.thread_variable_set(:i18n_config, current)
|
|
82
|
+
end
|
|
74
83
|
current
|
|
75
84
|
end
|
|
76
85
|
|
|
77
86
|
# Sets I18n configuration object.
|
|
78
87
|
def config=(value)
|
|
79
|
-
Fiber[
|
|
80
|
-
|
|
88
|
+
if Fiber.respond_to?(:[])
|
|
89
|
+
Fiber[:i18n_config] = value
|
|
90
|
+
value.owner = Fiber.current if value.respond_to?(:owner=) && !value.frozen?
|
|
91
|
+
else
|
|
92
|
+
Thread.current.thread_variable_set(:i18n_config, value)
|
|
93
|
+
end
|
|
81
94
|
end
|
|
82
95
|
|
|
83
96
|
# Write methods which delegates to the configuration object
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: i18n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.15.
|
|
4
|
+
version: 1.15.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Fuchs
|
|
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
97
97
|
requirements:
|
|
98
98
|
- - ">="
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
|
-
version: '3.
|
|
100
|
+
version: '3.1'
|
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
requirements:
|
|
103
103
|
- - ">="
|