i18n-active_record 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i18n/active_record/version.rb +1 -1
- data/lib/i18n/backend/active_record/translation.rb +9 -3
- data/lib/i18n/backend/active_record.rb +1 -1
- data/test/active_record_test.rb +1 -1
- data/test/test_helper.rb +18 -12
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696d09fb79116c47ec3924b359f31ba4c632d68a075d6da1af591dcb0412548f
|
4
|
+
data.tar.gz: eff1a17efd57a2f09546e80aa0d1269b07751f8615b65377c891d89186407d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dc72a6d40f4ce0da1d98f5ade7bc26f660766aa72814771f359b9c6c8e943a4c51acfce8f612794cd3ede72c3ad9808e9442524c951fded1c2ec2457be0201f
|
7
|
+
data.tar.gz: cc0fcb1c5121cefa325f52c4edbae8308a095d896cd6a8e3917d5c0144c1460f4f7795a4de6be9f25f399e678b4ce9fa2e95472e0cd651ee08aeead47e30ab03
|
data/README.md
CHANGED
@@ -115,7 +115,7 @@ The `interpolations` field is otherwise unused since the "value" in `Translation
|
|
115
115
|
|
116
116
|
## Examples
|
117
117
|
|
118
|
-
* http://collectiveidea.com/blog/archives/2016/05/31/beyond-yml-files-dynamic-translations/
|
118
|
+
* http://collectiveidea.com/blog/archives/2016/05/31/beyond-yml-files-dynamic-translations/ ([use `before_action`](https://github.com/svenfuchs/i18n-active_record/issues/138) for Rails 5.1+)
|
119
119
|
|
120
120
|
## Contributing
|
121
121
|
|
@@ -53,8 +53,14 @@ module I18n
|
|
53
53
|
|
54
54
|
self.table_name = 'translations'
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
if ::ActiveRecord.version >= Gem::Version.new('7.1.0.alpha')
|
57
|
+
serialize :value, coder: YAML
|
58
|
+
serialize :interpolations, coder: YAML, type: Array
|
59
|
+
else
|
60
|
+
serialize :value
|
61
|
+
serialize :interpolations, Array
|
62
|
+
end
|
63
|
+
|
58
64
|
after_commit :invalidate_translations_cache
|
59
65
|
|
60
66
|
class << self
|
@@ -79,7 +85,7 @@ module I18n
|
|
79
85
|
Translation.select('DISTINCT locale').to_a.map { |t| t.locale.to_sym }
|
80
86
|
end
|
81
87
|
|
82
|
-
def
|
88
|
+
def to_h
|
83
89
|
Translation.all.each.with_object({}) do |t, memo|
|
84
90
|
locale_hash = (memo[t.locale.to_sym] ||= {})
|
85
91
|
keys = t.key.split('.')
|
data/test/active_record_test.rb
CHANGED
@@ -123,7 +123,7 @@ class I18nBackendActiveRecordTest < I18n::TestCase
|
|
123
123
|
I18n.t('.') # Fixes test flakiness by loading available locales
|
124
124
|
I18n::Backend::ActiveRecord::Translation.destroy_all
|
125
125
|
|
126
|
-
|
126
|
+
assert_match(/[Tt]ranslation missing: en\.no key/, I18n.t('.'))
|
127
127
|
end
|
128
128
|
|
129
129
|
test 'intially unitinitialized' do
|
data/test/test_helper.rb
CHANGED
@@ -10,35 +10,35 @@ require 'i18n/tests'
|
|
10
10
|
|
11
11
|
begin
|
12
12
|
require 'active_record'
|
13
|
-
|
13
|
+
ActiveRecord::Base.connection
|
14
14
|
rescue LoadError => e
|
15
15
|
puts "can't use ActiveRecord backend because: #{e.message}"
|
16
|
-
rescue
|
16
|
+
rescue ActiveRecord::ConnectionNotEstablished
|
17
17
|
require 'i18n/backend/active_record'
|
18
18
|
|
19
|
-
case ENV
|
19
|
+
case ENV.fetch('DB', nil)
|
20
20
|
when 'postgres'
|
21
|
-
|
21
|
+
ActiveRecord::Base.establish_connection(
|
22
22
|
adapter: 'postgresql',
|
23
23
|
database: 'i18n_unittest',
|
24
|
-
username: ENV
|
25
|
-
password: ENV
|
24
|
+
username: ENV.fetch('PG_USER', 'postgres'),
|
25
|
+
password: ENV.fetch('PG_PASSWORD', 'postgres'),
|
26
26
|
host: 'localhost'
|
27
27
|
)
|
28
28
|
when 'mysql'
|
29
|
-
|
29
|
+
ActiveRecord::Base.establish_connection(
|
30
30
|
adapter: 'mysql2',
|
31
31
|
database: 'i18n_unittest',
|
32
|
-
username: ENV
|
33
|
-
password: ENV
|
32
|
+
username: ENV.fetch('MYSQL_USER', 'root'),
|
33
|
+
password: ENV.fetch('MYSQL_PASSWORD', ''),
|
34
34
|
host: '127.0.0.1'
|
35
35
|
)
|
36
36
|
else
|
37
|
-
|
37
|
+
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
ActiveRecord::Migration.verbose = false
|
41
|
+
ActiveRecord::Schema.define(version: 1) do
|
42
42
|
create_table :translations, force: true do |t|
|
43
43
|
t.string :locale
|
44
44
|
t.string :key
|
@@ -48,6 +48,12 @@ rescue ::ActiveRecord::ConnectionNotEstablished
|
|
48
48
|
end
|
49
49
|
add_index :translations, %i[locale key], unique: true
|
50
50
|
end
|
51
|
+
|
52
|
+
if ActiveRecord::Base.respond_to?(:yaml_column_permitted_classes=)
|
53
|
+
ActiveRecord::Base.yaml_column_permitted_classes = [Symbol]
|
54
|
+
elsif ActiveRecord.respond_to?(:yaml_column_permitted_classes=)
|
55
|
+
ActiveRecord.yaml_column_permitted_classes = [Symbol]
|
56
|
+
end
|
51
57
|
end
|
52
58
|
|
53
59
|
TEST_CASE = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
|
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
|
+
version: 1.2.0
|
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: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -150,7 +150,8 @@ files:
|
|
150
150
|
homepage: http://github.com/svenfuchs/i18n-active_record
|
151
151
|
licenses:
|
152
152
|
- MIT
|
153
|
-
metadata:
|
153
|
+
metadata:
|
154
|
+
rubygems_mfa_required: 'true'
|
154
155
|
post_install_message:
|
155
156
|
rdoc_options: []
|
156
157
|
require_paths:
|
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
167
|
- !ruby/object:Gem::Version
|
167
168
|
version: '0'
|
168
169
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.4.10
|
170
171
|
signing_key:
|
171
172
|
specification_version: 4
|
172
173
|
summary: I18n ActiveRecord backend
|