i18n-active_record 0.2.1 → 0.2.2
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/active_record/version.rb +1 -1
- data/lib/i18n/backend/active_record.rb +9 -2
- data/test/active_record_test.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b1b7eba888729976d370e18c88c1710d818e8d4
|
|
4
|
+
data.tar.gz: cc0b86a33d8742fc2cf6a2db0bf3891681bc7b1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 532cadaf5a7b6a349a4d84f5658be0c914521ec931e1c03089bd02d4e217279f080924568c8461c140ba3dd3d265eb5b3a017f817ec1723b91b6c6c4ca20aabd
|
|
7
|
+
data.tar.gz: c74ac31d2b20876ba61042b46de889f49f678f9fa23cf5d4173db7fc0d8ec4a878f779f03e53c76f563a051f99b2774fbcd7d28f3a7d9fe644cbf37b3880c184
|
|
@@ -49,7 +49,14 @@ module I18n
|
|
|
49
49
|
|
|
50
50
|
def lookup(locale, key, scope = [], options = {})
|
|
51
51
|
key = normalize_flat_keys(locale, key, scope, options[:separator])
|
|
52
|
-
|
|
52
|
+
if key.first == '.'
|
|
53
|
+
key = key[1..-1]
|
|
54
|
+
end
|
|
55
|
+
if key.last == '.'
|
|
56
|
+
key = key[0..-2]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
result = if key == ''
|
|
53
60
|
Translation.locale(locale).all
|
|
54
61
|
else
|
|
55
62
|
Translation.locale(locale).lookup(key)
|
|
@@ -69,7 +76,7 @@ module I18n
|
|
|
69
76
|
|
|
70
77
|
def build_translation_hash_by_key(lookup_key, translation)
|
|
71
78
|
hash = {}
|
|
72
|
-
if lookup_key == '
|
|
79
|
+
if lookup_key == ''
|
|
73
80
|
chop_range = 0..-1
|
|
74
81
|
else
|
|
75
82
|
chop_range = (lookup_key.size + FLATTEN_SEPARATOR.size)..-1
|
data/test/active_record_test.rb
CHANGED
|
@@ -94,6 +94,15 @@ class I18nBackendActiveRecordTest < I18n::TestCase
|
|
|
94
94
|
assert_equal expected_hash, I18n.t('.')
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
+
test "accessing keys with a trailing/leading period" do
|
|
98
|
+
expected_hash = { :bar => 'bar', :baz => 'baz' }
|
|
99
|
+
assert_equal expected_hash, I18n.t('foo')
|
|
100
|
+
assert_equal expected_hash, I18n.t('.foo')
|
|
101
|
+
assert_equal expected_hash, I18n.t('foo.')
|
|
102
|
+
assert_equal expected_hash, I18n.t('.foo.')
|
|
103
|
+
assert_equal expected_hash, I18n.t('.foo.')
|
|
104
|
+
end
|
|
105
|
+
|
|
97
106
|
test "returning all keys via . when there are no keys" do
|
|
98
107
|
I18n.t('.') # Fixes test flakiness by loading available locales
|
|
99
108
|
I18n::Backend::ActiveRecord::Translation.destroy_all
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: i18n-active_record
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Fuchs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: i18n
|