i18n 0.9.4 → 0.9.5
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/lib/i18n/backend/simple.rb +2 -1
- data/lib/i18n/version.rb +1 -1
- data/test/backend/simple_test.rb +15 -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: '09643c444c40fe98042352f7f3e3e2df08e15ec5bee9f3d658b3e2fdeeb627a7'
|
4
|
+
data.tar.gz: b924468907cca779632052d4ec166c79a9fc10f305a4a4f2c7be6ffeef6a5e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 338556073a2c02752c1d3e5e3ba5ed70cb692d814ab05aca5a3d70ef3ee013aa3bb9d5cfc6aecbbd2a93e4732105a4c05c70968ea7f955c169cf69ad97462796
|
7
|
+
data.tar.gz: a0a4eff7b73ac32730dae8b77f609c4cc6fca9b6c2f46d81f42d992e10dd8d1467dbc28985b38769f9cab2f6ac1d67e4309eb8a8df65d9fc38baa39b65343f18
|
data/lib/i18n/backend/simple.rb
CHANGED
@@ -29,7 +29,8 @@ module I18n
|
|
29
29
|
# translations will be overwritten by new ones only at the deepest
|
30
30
|
# level of the hash.
|
31
31
|
def store_translations(locale, data, options = {})
|
32
|
-
if I18n.
|
32
|
+
if I18n.enforce_available_locales &&
|
33
|
+
I18n.available_locales_initialized? &&
|
33
34
|
!I18n.available_locales.include?(locale.to_sym) &&
|
34
35
|
!I18n.available_locales.include?(locale.to_s)
|
35
36
|
return data
|
data/lib/i18n/version.rb
CHANGED
data/test/backend/simple_test.rb
CHANGED
@@ -70,12 +70,23 @@ class I18nBackendSimpleTest < I18n::TestCase
|
|
70
70
|
assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], translations
|
71
71
|
end
|
72
72
|
|
73
|
-
test "simple store_translations: do not store translations
|
73
|
+
test "simple store_translations: do not store translations unavailable locales if enforce_available_locales is true" do
|
74
|
+
begin
|
75
|
+
I18n.enforce_available_locales = true
|
76
|
+
I18n.available_locales = [:en, :es]
|
77
|
+
store_translations(:fr, :foo => {:bar => 'barfr', :baz => 'bazfr'})
|
78
|
+
store_translations(:es, :foo => {:bar => 'bares', :baz => 'bazes'})
|
79
|
+
assert_nil translations[:fr]
|
80
|
+
assert_equal Hash[:foo, {:bar => 'bares', :baz => 'bazes'}], translations[:es]
|
81
|
+
ensure
|
82
|
+
I18n.config.enforce_available_locales = false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
test "simple store_translations: store translations for unavailable locales if enforce_available_locales is false" do
|
74
87
|
I18n.available_locales = [:en, :es]
|
75
88
|
store_translations(:fr, :foo => {:bar => 'barfr', :baz => 'bazfr'})
|
76
|
-
|
77
|
-
assert_nil translations[:fr]
|
78
|
-
assert_equal Hash[:foo, {:bar => 'bares', :baz => 'bazes'}], translations[:es]
|
89
|
+
assert_equal Hash[:foo, {:bar => 'barfr', :baz => 'bazfr'}], translations[:fr]
|
79
90
|
end
|
80
91
|
|
81
92
|
# reloading translations
|
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: 0.9.
|
4
|
+
version: 0.9.5
|
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: 2018-02-
|
16
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|