i18n-active_record 1.4.0 → 1.4.1
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/README.md +1 -1
- data/lib/i18n/active_record/version.rb +1 -1
- data/lib/i18n/backend/active_record.rb +5 -1
- data/test/active_record_test.rb +4 -0
- data/test/test_helper.rb +2 -0
- 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: 26219413730c53c1670e481938d6433aadcb1efec49430b5e91dd6cba431f360
|
|
4
|
+
data.tar.gz: ae147b2a40b8d31fa3c4d682168fb5a95d3dd97f31b9eca47910c9f07cc87a37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 796e5d5a521f0dea36d30aed6c2044e62438633dcf062c7f0f18ad52f546bf1b69e7350dc971cac714924c50d0d372d7b978c75b214a44bdbf1bddfdc06ea9ba
|
|
7
|
+
data.tar.gz: bb4e08743709d44b03c749c9dab82f2fb968df78c953183c4cda43f4d66e80815d20e627500f522c3390ce7954e6d0a9c4c94eded68911737e1dbc856c476c43
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# I18n::Backend::ActiveRecord [](https://github.com/rubocop/rubocop) [](https://github.com/svenfuchs/i18n-active_record/actions) [](https://github.com/svenfuchs/i18n-active_record/actions)
|
|
2
2
|
|
|
3
3
|
This repository contains the I18n ActiveRecord backend and support code that has been extracted from the `I18n` gem: http://github.com/svenfuchs/i18n.
|
|
4
|
-
It is fully compatible with Rails 4
|
|
4
|
+
It is fully compatible with Rails 4 and higher.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -91,7 +91,7 @@ module I18n
|
|
|
91
91
|
if self.class.config.cache_translations
|
|
92
92
|
keys = ([locale] + key.split(I18n::Backend::Flatten::FLATTEN_SEPARATOR)).map(&:to_sym)
|
|
93
93
|
|
|
94
|
-
return
|
|
94
|
+
return lookup_in_cache(keys)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
result = if key == ''
|
|
@@ -112,6 +112,10 @@ module I18n
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
def lookup_in_cache(keys)
|
|
116
|
+
keys.inject(translations) { |node, part| node[part] if node.is_a?(Hash) }
|
|
117
|
+
end
|
|
118
|
+
|
|
115
119
|
def build_translation_hash_by_key(lookup_key, translation)
|
|
116
120
|
hash = {}
|
|
117
121
|
|
data/test/active_record_test.rb
CHANGED
|
@@ -96,6 +96,10 @@ class I18nBackendActiveRecordTest < I18n::TestCase
|
|
|
96
96
|
assert_equal I18n.t(:foo), { bar: { fizz: 'buzz', spuz: 'zazz' }, baz: { fizz: 'buzz' } }
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
test 'lookup of a key nested under a translation returns nothing' do
|
|
100
|
+
assert_equal 'default', I18n.t('foo.bar.baz', default: 'default')
|
|
101
|
+
end
|
|
102
|
+
|
|
99
103
|
test 'build_translation_hash_by_key' do
|
|
100
104
|
translation = I18n::Backend::ActiveRecord::Translation.new(value: 'translation', key: 'foo.bar.fizz.buzz')
|
|
101
105
|
expected_hash = { 'bar' => { 'fizz' => { 'buzz' => 'translation' } } }
|
data/test/test_helper.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'bundler/setup'
|
|
4
|
+
require 'logger' # Rails 6.1 expects it to be loaded, recent concurrent-ruby no longer does that
|
|
4
5
|
require 'minitest/autorun'
|
|
5
6
|
require 'mocha/minitest'
|
|
6
7
|
require 'test_declarative'
|
|
@@ -29,6 +30,7 @@ rescue ActiveRecord::ConnectionNotEstablished
|
|
|
29
30
|
ActiveRecord::Base.establish_connection(
|
|
30
31
|
adapter: 'mysql2',
|
|
31
32
|
database: 'i18n_unittest',
|
|
33
|
+
encoding: 'utf8mb4',
|
|
32
34
|
username: ENV.fetch('MYSQL_USER', 'root'),
|
|
33
35
|
password: ENV.fetch('MYSQL_PASSWORD', ''),
|
|
34
36
|
host: '127.0.0.1'
|
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: 1.4.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sven Fuchs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: i18n
|