i18n 1.13.0 → 1.14.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/lazy_loadable.rb +1 -1
- data/lib/i18n/exceptions.rb +12 -2
- data/lib/i18n/tests/localization/date.rb +1 -1
- data/lib/i18n/tests/localization/date_time.rb +1 -1
- data/lib/i18n/tests/localization/time.rb +1 -1
- data/lib/i18n/tests/lookup.rb +1 -1
- data/lib/i18n/version.rb +1 -1
- data/lib/i18n.rb +5 -4
- 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: 56f42c8544a7ce959616902c3a1dcabe350581001f708b43883504995c29835a
|
4
|
+
data.tar.gz: 8502fbd1b16386dc75b9feac93e023915671ade132423b04538324e8c855de8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b19cf52d0c49c3f521d3917958b47a235d61d374af806ade81da6092bf68577153012cf98cb61c85b4f951284a96aeace9280c8ca64d78e6f0b7546ef3f8d64
|
7
|
+
data.tar.gz: ac025237950bb63b2f66ff28ceb9cadb9de16bd9b55853ee47a48f61552c5192805bbc4415e4f8394481c74130c8163938707cf861ad65d58438636be096ccae
|
@@ -98,7 +98,7 @@ module I18n
|
|
98
98
|
# Parse the load path and extract all locales.
|
99
99
|
def available_locales
|
100
100
|
if lazy_load?
|
101
|
-
I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }
|
101
|
+
I18n.load_path.map { |path| LocaleExtractor.locale_from_path(path) }.uniq
|
102
102
|
else
|
103
103
|
super
|
104
104
|
end
|
data/lib/i18n/exceptions.rb
CHANGED
@@ -47,7 +47,7 @@ module I18n
|
|
47
47
|
|
48
48
|
class MissingTranslation < ArgumentError
|
49
49
|
module Base
|
50
|
-
PERMITTED_KEYS = [:scope].freeze
|
50
|
+
PERMITTED_KEYS = [:scope, :default].freeze
|
51
51
|
|
52
52
|
attr_reader :locale, :key, :options
|
53
53
|
|
@@ -63,8 +63,18 @@ module I18n
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def message
|
66
|
-
|
66
|
+
if options[:default].is_a?(Array)
|
67
|
+
other_options = ([key, *options[:default]]).map { |k| normalized_option(k).prepend('- ') }.join("\n")
|
68
|
+
"Translation missing. Options considered were:\n#{other_options}"
|
69
|
+
else
|
70
|
+
"Translation missing: #{keys.join('.')}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def normalized_option(key)
|
75
|
+
I18n.normalize_keys(locale, key, options[:scope]).join('.')
|
67
76
|
end
|
77
|
+
|
68
78
|
alias :to_s :message
|
69
79
|
|
70
80
|
def to_exception
|
@@ -64,7 +64,7 @@ module I18n
|
|
64
64
|
end
|
65
65
|
|
66
66
|
test "localize Date: given missing translations it returns the correct error message" do
|
67
|
-
assert_equal '
|
67
|
+
assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr)
|
68
68
|
end
|
69
69
|
|
70
70
|
test "localize Date: given an unknown format it does not fail" do
|
@@ -60,7 +60,7 @@ module I18n
|
|
60
60
|
end
|
61
61
|
|
62
62
|
test "localize DateTime: given missing translations it returns the correct error message" do
|
63
|
-
assert_equal '
|
63
|
+
assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@datetime, :format => '%b', :locale => :fr)
|
64
64
|
end
|
65
65
|
|
66
66
|
test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do
|
@@ -61,7 +61,7 @@ module I18n
|
|
61
61
|
end
|
62
62
|
|
63
63
|
test "localize Time: given missing translations it returns the correct error message" do
|
64
|
-
assert_equal '
|
64
|
+
assert_equal 'Translation missing: fr.date.abbr_month_names', I18n.l(@time, :format => '%b', :locale => :fr)
|
65
65
|
end
|
66
66
|
|
67
67
|
test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
|
data/lib/i18n/tests/lookup.rb
CHANGED
@@ -30,7 +30,7 @@ module I18n
|
|
30
30
|
end
|
31
31
|
|
32
32
|
test "lookup: given a missing key, no default and no raise option it returns an error message" do
|
33
|
-
assert_equal "
|
33
|
+
assert_equal "Translation missing: en.missing", I18n.t(:missing)
|
34
34
|
end
|
35
35
|
|
36
36
|
test "lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do
|
data/lib/i18n/version.rb
CHANGED
data/lib/i18n.rb
CHANGED
@@ -331,11 +331,12 @@ module I18n
|
|
331
331
|
# keys are Symbols.
|
332
332
|
def normalize_keys(locale, key, scope, separator = nil)
|
333
333
|
separator ||= I18n.default_separator
|
334
|
-
locale = locale.to_sym if locale
|
335
334
|
|
336
|
-
|
337
|
-
|
338
|
-
|
335
|
+
[
|
336
|
+
*normalize_key(locale, separator),
|
337
|
+
*normalize_key(scope, separator),
|
338
|
+
*normalize_key(key, separator)
|
339
|
+
]
|
339
340
|
end
|
340
341
|
|
341
342
|
# Returns true when the passed locale, which can be either a String or a
|
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.14.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: 2023-
|
16
|
+
date: 2023-06-02 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|