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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f11d7fde969b3ef11eee86da2995a54d9f5c2c
4
- data.tar.gz: fb23e1d54a386e6b856323cd1f222d9e0766b39d
3
+ metadata.gz: 6b1b7eba888729976d370e18c88c1710d818e8d4
4
+ data.tar.gz: cc0b86a33d8742fc2cf6a2db0bf3891681bc7b1c
5
5
  SHA512:
6
- metadata.gz: b135f6d2c44c8e36c4856b60c287788d63b753dfe0991765062d4b416dfb587ef2b9e3e6ebae0b89fe9640017e4c57ecf78e6b566b4a871dbc5d14c1caea56fc
7
- data.tar.gz: 49a3c2fc3b68f94298355a22ffe4547e3b8693ee2cf3f91faa2707e87bbfcc6e3ef259c25aab9363a8dfad0beec81627ebf06cfc543ea0f02fd7d78c63c33604
6
+ metadata.gz: 532cadaf5a7b6a349a4d84f5658be0c914521ec931e1c03089bd02d4e217279f080924568c8461c140ba3dd3d265eb5b3a017f817ec1723b91b6c6c4ca20aabd
7
+ data.tar.gz: c74ac31d2b20876ba61042b46de889f49f678f9fa23cf5d4173db7fc0d8ec4a878f779f03e53c76f563a051f99b2774fbcd7d28f3a7d9fe644cbf37b3880c184
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module ActiveRecord
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
@@ -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
- result = if key == '.'
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
@@ -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.1
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-17 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n