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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6895e3f4b2c615221ac6a44bba495f6a6557e76fe5815fe604005e3e9d455d0
4
- data.tar.gz: febd2054212ebeec7624de340aebc0c9f86ae4ec509f55751f97459adef82bf9
3
+ metadata.gz: 26219413730c53c1670e481938d6433aadcb1efec49430b5e91dd6cba431f360
4
+ data.tar.gz: ae147b2a40b8d31fa3c4d682168fb5a95d3dd97f31b9eca47910c9f07cc87a37
5
5
  SHA512:
6
- metadata.gz: 3fbd83d43d6158a23eb0573a598c87c23986912403496761d60b9e72950d06ff0897e6e911bb2f3d1073ab0066e17d7aa02c0f288e6b2f43bacad3f306f31625
7
- data.tar.gz: b51858da9da92d578fe190a185e45df9779e34dfb07c5b8daf097059edf18394c83fbbb1f2add6ac72b59e8ff19342f1ba3190bb72bee322a4430e25decce5ae
6
+ metadata.gz: 796e5d5a521f0dea36d30aed6c2044e62438633dcf062c7f0f18ad52f546bf1b69e7350dc971cac714924c50d0d372d7b978c75b214a44bdbf1bddfdc06ea9ba
7
+ data.tar.gz: bb4e08743709d44b03c749c9dab82f2fb968df78c953183c4cda43f4d66e80815d20e627500f522c3390ce7954e6d0a9c4c94eded68911737e1dbc856c476c43
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # I18n::Backend::ActiveRecord [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) [![Tests Status](https://github.com/svenfuchs/i18n-active_record/actions/workflows/test.yml/badge.svg)](https://github.com/svenfuchs/i18n-active_record/actions) [![Linter Status](https://github.com/svenfuchs/i18n-active_record/actions/workflows/linter.yml/badge.svg)](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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module ActiveRecord
5
- VERSION = '1.4.0'
5
+ VERSION = '1.4.1'
6
6
  end
7
7
  end
@@ -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 translations.dig(*keys)
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
 
@@ -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.0
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: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2026-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n