i18n 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i18n.rb +3 -3
- data/lib/i18n/backend/base.rb +3 -3
- data/lib/i18n/backend/chain.rb +7 -3
- data/lib/i18n/backend/simple.rb +0 -2
- data/lib/i18n/gettext/helpers.rb +1 -1
- data/lib/i18n/interpolate/ruby.rb +1 -1
- data/lib/i18n/locale/fallbacks.rb +1 -0
- data/lib/i18n/tests/interpolation.rb +4 -0
- data/lib/i18n/tests/localization/date.rb +2 -2
- data/lib/i18n/tests/localization/procs.rb +1 -1
- data/lib/i18n/tests/lookup.rb +2 -2
- data/lib/i18n/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd80c4dac859bf40aa5a70cab46357ea469fe054757dc747d8976a243e619bb0
|
4
|
+
data.tar.gz: f396a7f27e9295a336dbccc489828439816de7dbc7b7fd5f8bd7863c907d813a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1be60c0724e1bb2054dfaecc1f732d3a6d52e2eaa600947899938f591b0cbb3af43614d57e2157d9f6a35f18b8b3119e65cba605b32cef33c4e361be2e84f9aa
|
7
|
+
data.tar.gz: 973b4f37394853d37b10a8801cc6d3b33f934601ccd492a1c93df6f05c13cb780068403c4e12216d0a831489babd0fcec9eb04ad0c68ebbaf57a94b76ad24ed2
|
data/README.md
CHANGED
@@ -95,7 +95,7 @@ particular tests in different test cases.
|
|
95
95
|
The reason for this is that we need to enforce the I18n API across various
|
96
96
|
combinations of extensions. E.g. the Simple backend alone needs to support
|
97
97
|
the same API as any combination of feature and/or optimization modules included
|
98
|
-
to the Simple backend. We test this by reusing the same API
|
98
|
+
to the Simple backend. We test this by reusing the same API definition (implemented
|
99
99
|
as test methods) in test cases with different setups.
|
100
100
|
|
101
101
|
You can find the test cases that enforce the API in test/api. And you can find
|
data/lib/i18n.rb
CHANGED
@@ -115,7 +115,7 @@ module I18n
|
|
115
115
|
# *PLURALIZATION*
|
116
116
|
#
|
117
117
|
# Translation data can contain pluralized translations. Pluralized translations
|
118
|
-
# are arrays of
|
118
|
+
# are arrays of singular/plural versions of translations like <tt>['Foo', 'Foos']</tt>.
|
119
119
|
#
|
120
120
|
# Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English
|
121
121
|
# pluralization rules. Other algorithms can be supported by custom backends.
|
@@ -173,7 +173,7 @@ module I18n
|
|
173
173
|
#
|
174
174
|
# It is recommended to use/implement lambdas in an "idempotent" way. E.g. when
|
175
175
|
# a cache layer is put in front of I18n.translate it will generate a cache key
|
176
|
-
# from the argument values passed to #translate.
|
176
|
+
# from the argument values passed to #translate. Therefore your lambdas should
|
177
177
|
# always return the same translations/values per unique combination of argument
|
178
178
|
# values.
|
179
179
|
def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
|
@@ -202,7 +202,7 @@ module I18n
|
|
202
202
|
# Wrapper for <tt>translate</tt> that adds <tt>:raise => true</tt>. With
|
203
203
|
# this option, if no translation is found, it will raise <tt>I18n::MissingTranslationData</tt>
|
204
204
|
def translate!(key, options = EMPTY_HASH)
|
205
|
-
translate(key, options.merge(:raise => true))
|
205
|
+
translate(key, **options.merge(:raise => true))
|
206
206
|
end
|
207
207
|
alias :t! :translate!
|
208
208
|
|
data/lib/i18n/backend/base.rb
CHANGED
@@ -81,7 +81,7 @@ module I18n
|
|
81
81
|
key = format
|
82
82
|
type = object.respond_to?(:sec) ? 'time' : 'date'
|
83
83
|
options = options.merge(:raise => true, :object => object, :locale => locale)
|
84
|
-
format = I18n.t(:"#{type}.formats.#{key}", options)
|
84
|
+
format = I18n.t(:"#{type}.formats.#{key}", **options)
|
85
85
|
end
|
86
86
|
|
87
87
|
format = translate_localization_format(locale, object, format, options)
|
@@ -122,7 +122,7 @@ module I18n
|
|
122
122
|
# first translation that can be resolved. Otherwise it tries to resolve
|
123
123
|
# the translation directly.
|
124
124
|
def default(locale, object, subject, options = EMPTY_HASH)
|
125
|
-
options = options.
|
125
|
+
options = options.reject { |key, value| key == :default }
|
126
126
|
case subject
|
127
127
|
when Array
|
128
128
|
subject.each do |item|
|
@@ -143,7 +143,7 @@ module I18n
|
|
143
143
|
result = catch(:exception) do
|
144
144
|
case subject
|
145
145
|
when Symbol
|
146
|
-
I18n.translate(subject, options.merge(:locale => locale, :throw => true))
|
146
|
+
I18n.translate(subject, **options.merge(:locale => locale, :throw => true))
|
147
147
|
when Proc
|
148
148
|
date_or_time = options.delete(:object) || object
|
149
149
|
resolve(locale, object, subject.call(date_or_time, options))
|
data/lib/i18n/backend/chain.rb
CHANGED
@@ -96,9 +96,13 @@ module I18n
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def translations
|
99
|
-
backends.
|
100
|
-
|
101
|
-
|
99
|
+
backends.reverse.each_with_object({}) do |backend, memo|
|
100
|
+
partial_translations = backend.instance_eval do
|
101
|
+
init_translations unless initialized?
|
102
|
+
translations
|
103
|
+
end
|
104
|
+
|
105
|
+
memo.deep_merge!(partial_translations)
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
data/lib/i18n/backend/simple.rb
CHANGED
data/lib/i18n/gettext/helpers.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
module I18n
|
5
5
|
DEFAULT_INTERPOLATION_PATTERNS = [
|
6
6
|
/%%/,
|
7
|
-
/%\{(\w+)\}/,
|
7
|
+
/%\{([\w|]+)\}/, # matches placeholders like "%{foo} or %{foo|word}"
|
8
8
|
/%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
|
9
9
|
].freeze
|
10
10
|
INTERPOLATION_PATTERN = Regexp.union(DEFAULT_INTERPOLATION_PATTERNS)
|
@@ -24,6 +24,10 @@ module I18n
|
|
24
24
|
assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David')
|
25
25
|
end
|
26
26
|
|
27
|
+
test "interpolation: works with a pipe" do
|
28
|
+
assert_equal 'Hi david!', interpolate(:default => 'Hi %{name|lowercase}!', :'name|lowercase' => 'david')
|
29
|
+
end
|
30
|
+
|
27
31
|
test "interpolation: given a nil value it still interpolates it into the string" do
|
28
32
|
assert_equal 'Hi !', interpolate(:default => 'Hi %{name}!', :name => nil)
|
29
33
|
end
|
@@ -68,9 +68,9 @@ module I18n
|
|
68
68
|
|
69
69
|
test "localize Date: does not modify the options hash" do
|
70
70
|
options = { :format => '%b', :locale => :de }
|
71
|
-
assert_equal 'Mär', I18n.l(@date, options)
|
71
|
+
assert_equal 'Mär', I18n.l(@date, **options)
|
72
72
|
assert_equal({ :format => '%b', :locale => :de }, options)
|
73
|
-
assert_nothing_raised { I18n.l(@date, options.freeze) }
|
73
|
+
assert_nothing_raised { I18n.l(@date, **options.freeze) }
|
74
74
|
end
|
75
75
|
|
76
76
|
test "localize Date: given nil with default value it returns default" do
|
@@ -59,7 +59,7 @@ module I18n
|
|
59
59
|
setup_time_proc_translations
|
60
60
|
time = ::Time.utc(2008, 3, 1, 6, 0)
|
61
61
|
options = { :foo => 'foo' }
|
62
|
-
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, options]), I18n.l(time, options.merge(:format => :proc, :locale => :ru))
|
62
|
+
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, options]), I18n.l(time, **options.merge(:format => :proc, :locale => :ru))
|
63
63
|
end
|
64
64
|
|
65
65
|
protected
|
data/lib/i18n/tests/lookup.rb
CHANGED
@@ -43,9 +43,9 @@ module I18n
|
|
43
43
|
|
44
44
|
test "lookup: does not modify the options hash" do
|
45
45
|
options = {}
|
46
|
-
assert_equal "a", I18n.t(:string, options)
|
46
|
+
assert_equal "a", I18n.t(:string, **options)
|
47
47
|
assert_equal({}, options)
|
48
|
-
assert_nothing_raised { I18n.t(:string, options.freeze) }
|
48
|
+
assert_nothing_raised { I18n.t(:string, **options.freeze) }
|
49
49
|
end
|
50
50
|
|
51
51
|
test "lookup: given an array of keys it translates all of them" do
|
data/lib/i18n/version.rb
CHANGED
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.7.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: 2019-
|
16
|
+
date: 2019-10-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|
@@ -82,7 +82,7 @@ files:
|
|
82
82
|
- lib/i18n/tests/pluralization.rb
|
83
83
|
- lib/i18n/tests/procs.rb
|
84
84
|
- lib/i18n/version.rb
|
85
|
-
homepage:
|
85
|
+
homepage: https://github.com/ruby-i18n/i18n
|
86
86
|
licenses:
|
87
87
|
- MIT
|
88
88
|
metadata:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 1.3.5
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.0.
|
120
|
+
rubygems_version: 3.0.3
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: New wave Internationalization support for Ruby
|