i18n 1.13.0 → 1.14.1
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/chain.rb +2 -0
- 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: 692bec57675f1d97cdd0dff4a7b444e1777ba2f360dc3cf7162d5a98e45ab0a5
|
4
|
+
data.tar.gz: 954df8c7788ce253f730e4bf6911373198b26c24c2274113b2e12b6d6527b486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ebf6f4edea8d2a6cf511496bcad2c0e50323c44263c4d27e44f12860f9e4e35e093514bb1fb3cd9925591b5e3db62917af79ee2710b4cc759735dd1ff4d538
|
7
|
+
data.tar.gz: 1764731c2157cddb200a8dec9286248f7fac4e8a23548305aa09e70b5591d924748179c9534bb46cd6d7d892987963566d95e20854d5928b51a0fbad76dded3b
|
data/lib/i18n/backend/chain.rb
CHANGED
@@ -16,6 +16,8 @@ module I18n
|
|
16
16
|
#
|
17
17
|
# The implementation assumes that all backends added to the Chain implement
|
18
18
|
# a lookup method with the same API as Simple backend does.
|
19
|
+
#
|
20
|
+
# Fallback translations using the :default option are only used by the last backend of a chain.
|
19
21
|
class Chain
|
20
22
|
module Implementation
|
21
23
|
include Base
|
@@ -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 (default = options[:default]).is_a?(Array) && default.any?
|
67
|
+
other_options = ([key, *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.1
|
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-04
|
16
|
+
date: 2023-06-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|