i18n 1.10.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n/backend/fallbacks.rb +1 -1
- data/lib/i18n/config.rb +2 -2
- data/lib/i18n/exceptions.rb +1 -1
- data/lib/i18n/locale/tag/simple.rb +1 -1
- data/lib/i18n/tests/basics.rb +2 -2
- data/lib/i18n/version.rb +1 -1
- data/lib/i18n.rb +16 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b92d195deaeca5e93f73cc62be2d2fb4c93d8a9787449e168b493773e5072458
|
4
|
+
data.tar.gz: f1172c9fac93f493c8a5b16cff4b27154ff917aed48cbc46a4a702363863111d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0174d10f7bac17e29cf7622d3ce69850e51755d53fd3d17d2f672bc9ca3c75823b851f6d04cbd367fea8ff5830c8c755fb9c80433bac9ec3c46590cbe9a874d0
|
7
|
+
data.tar.gz: ef22ed98cb7f223753a65b9d63d0f40e4b6821c93a41b1b41627e4c7b4e3de6b7bd411d8a6ed3d46dc6554432a776535c0461248e8d1fbfeee05dcda2ab89235
|
@@ -107,7 +107,7 @@ module I18n
|
|
107
107
|
private
|
108
108
|
|
109
109
|
# Overwrite on_fallback to add specified logic when the fallback succeeds.
|
110
|
-
def on_fallback(_original_locale, _fallback_locale, _key,
|
110
|
+
def on_fallback(_original_locale, _fallback_locale, _key, _options)
|
111
111
|
nil
|
112
112
|
end
|
113
113
|
end
|
data/lib/i18n/config.rb
CHANGED
@@ -38,7 +38,7 @@ module I18n
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Returns an array of locales for which translations are available.
|
41
|
-
# Unless you
|
41
|
+
# Unless you explicitly set these through I18n.available_locales=
|
42
42
|
# the call will be delegated to the backend.
|
43
43
|
def available_locales
|
44
44
|
@@available_locales ||= nil
|
@@ -106,7 +106,7 @@ module I18n
|
|
106
106
|
# if you don't care about arity.
|
107
107
|
#
|
108
108
|
# == Example:
|
109
|
-
# You can
|
109
|
+
# You can suppress raising an exception and return string instead:
|
110
110
|
#
|
111
111
|
# I18n.config.missing_interpolation_argument_handler = Proc.new do |key|
|
112
112
|
# "#{key} is missing"
|
data/lib/i18n/exceptions.rb
CHANGED
@@ -24,7 +24,7 @@ module I18n
|
|
24
24
|
been set is likely to display text from the wrong locale to some users.
|
25
25
|
|
26
26
|
If you have a legitimate reason to access i18n data outside of the user flow, you can do so by passing
|
27
|
-
the desired locale
|
27
|
+
the desired locale explicitly with the `locale` argument, e.g. `I18n.#{method}(..., locale: :en)`
|
28
28
|
MESSAGE
|
29
29
|
end
|
30
30
|
end
|
data/lib/i18n/tests/basics.rb
CHANGED
@@ -26,7 +26,7 @@ module I18n
|
|
26
26
|
assert_equal I18n.available_locales, I18n.backend.available_locales
|
27
27
|
end
|
28
28
|
|
29
|
-
test "available_locales memoizes when set
|
29
|
+
test "available_locales memoizes when set explicitly" do
|
30
30
|
I18n.backend.expects(:available_locales).never
|
31
31
|
I18n.available_locales = [:foo]
|
32
32
|
I18n.backend.store_translations('de', :bar => 'baz')
|
@@ -34,7 +34,7 @@ module I18n
|
|
34
34
|
assert_equal [:foo], I18n.available_locales
|
35
35
|
end
|
36
36
|
|
37
|
-
test "available_locales delegates to the backend when not set
|
37
|
+
test "available_locales delegates to the backend when not set explicitly" do
|
38
38
|
original_available_locales_value = I18n.backend.available_locales
|
39
39
|
I18n.backend.expects(:available_locales).returns(original_available_locales_value).twice
|
40
40
|
assert_equal I18n.backend.available_locales, I18n.available_locales
|
data/lib/i18n/version.rb
CHANGED
data/lib/i18n.rb
CHANGED
@@ -214,18 +214,12 @@ module I18n
|
|
214
214
|
|
215
215
|
backend = config.backend
|
216
216
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
else
|
221
|
-
backend.translate(locale, key, options)
|
217
|
+
if key.is_a?(Array)
|
218
|
+
key.map do |k|
|
219
|
+
translate_key(k, throw, raise, locale, backend, options)
|
222
220
|
end
|
223
|
-
end
|
224
|
-
|
225
|
-
if result.is_a?(MissingTranslation)
|
226
|
-
handle_exception((throw && :throw || raise && :raise), result, locale, key, options)
|
227
221
|
else
|
228
|
-
|
222
|
+
translate_key(key, throw, raise, locale, backend, options)
|
229
223
|
end
|
230
224
|
end
|
231
225
|
alias :t :translate
|
@@ -364,6 +358,18 @@ module I18n
|
|
364
358
|
|
365
359
|
private
|
366
360
|
|
361
|
+
def translate_key(key, throw, raise, locale, backend, options)
|
362
|
+
result = catch(:exception) do
|
363
|
+
backend.translate(locale, key, options)
|
364
|
+
end
|
365
|
+
|
366
|
+
if result.is_a?(MissingTranslation)
|
367
|
+
handle_exception((throw && :throw || raise && :raise), result, locale, key, options)
|
368
|
+
else
|
369
|
+
result
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
367
373
|
# Any exceptions thrown in translate will be sent to the @@exception_handler
|
368
374
|
# which can be a Symbol, a Proc or any other Object unless they're forced to
|
369
375
|
# be raised or thrown (MissingTranslation).
|
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.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2022-
|
16
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: 1.3.5
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.3.16
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: New wave Internationalization support for Ruby
|