i18n-active_record 0.3.0 → 1.0.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 +140 -0
- data/Rakefile +3 -52
- data/lib/generators/i18n/active_record/install_generator.rb +4 -2
- data/lib/generators/i18n/active_record/templates/advanced_initializer.rb.erb +1 -0
- data/lib/generators/i18n/active_record/templates/migration.rb.erb +6 -10
- data/lib/generators/i18n/active_record/templates/simple_initializer.rb.erb +1 -0
- data/lib/i18n/active_record/version.rb +3 -1
- data/lib/i18n/active_record.rb +2 -0
- data/lib/i18n/backend/active_record/configuration.rb +4 -1
- data/lib/i18n/backend/active_record/missing.rb +11 -8
- data/lib/i18n/backend/active_record/store_procs.rb +6 -5
- data/lib/i18n/backend/active_record/translation.rb +27 -7
- data/lib/i18n/backend/active_record.rb +89 -60
- data/test/active_record_test.rb +142 -79
- data/test/api_test.rb +4 -1
- data/test/missing_test.rb +85 -48
- data/test/test_helper.rb +51 -39
- metadata +91 -7
- data/README.textile +0 -109
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: appraisal
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,76 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: test_declarative
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
41
125
|
description: I18n ActiveRecord backend. Allows to store translations in a database
|
42
126
|
using ActiveRecord, e.g. for providing a web-interface for managing translations.
|
43
127
|
email: svenfuchs@artweb-design.de
|
@@ -46,7 +130,7 @@ extensions: []
|
|
46
130
|
extra_rdoc_files: []
|
47
131
|
files:
|
48
132
|
- MIT-LICENSE
|
49
|
-
- README.
|
133
|
+
- README.md
|
50
134
|
- Rakefile
|
51
135
|
- lib/generators/i18n/active_record/install_generator.rb
|
52
136
|
- lib/generators/i18n/active_record/templates/advanced_initializer.rb.erb
|
@@ -67,7 +151,7 @@ homepage: http://github.com/svenfuchs/i18n-active_record
|
|
67
151
|
licenses:
|
68
152
|
- MIT
|
69
153
|
metadata: {}
|
70
|
-
post_install_message:
|
154
|
+
post_install_message:
|
71
155
|
rdoc_options: []
|
72
156
|
require_paths:
|
73
157
|
- lib
|
@@ -82,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
166
|
- !ruby/object:Gem::Version
|
83
167
|
version: '0'
|
84
168
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
86
|
-
signing_key:
|
169
|
+
rubygems_version: 3.2.29
|
170
|
+
signing_key:
|
87
171
|
specification_version: 4
|
88
172
|
summary: I18n ActiveRecord backend
|
89
173
|
test_files: []
|
data/README.textile
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
h1. I18n::Backend::ActiveRecord
|
2
|
-
|
3
|
-
!https://travis-ci.org/svenfuchs/i18n-active_record.svg?branch=master!:https://travis-ci.org/svenfuchs/i18n-active_record
|
4
|
-
|
5
|
-
This repository contains the I18n ActiveRecord backend and support code that has been extracted from the "I18n":http://github.com/svenfuchs/i18n.
|
6
|
-
It is fully compatible with Rails 3, 4 and 5
|
7
|
-
|
8
|
-
h2. Installation
|
9
|
-
|
10
|
-
For Bundler put the following in your Gemfile:
|
11
|
-
|
12
|
-
<pre>
|
13
|
-
gem 'i18n-active_record', :require => 'i18n/active_record'
|
14
|
-
</pre>
|
15
|
-
|
16
|
-
After updating your bundle, run the installer
|
17
|
-
|
18
|
-
<pre>
|
19
|
-
rails g i18n:active_record:install
|
20
|
-
</pre>
|
21
|
-
|
22
|
-
It creates a migration:
|
23
|
-
|
24
|
-
<pre>
|
25
|
-
class CreateTranslations < ActiveRecord::Migration
|
26
|
-
def self.up
|
27
|
-
create_table :translations do |t|
|
28
|
-
t.string :locale
|
29
|
-
t.string :key
|
30
|
-
t.text :value
|
31
|
-
t.text :interpolations
|
32
|
-
t.boolean :is_proc, :default => false
|
33
|
-
|
34
|
-
t.timestamps
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.down
|
39
|
-
drop_table :translations
|
40
|
-
end
|
41
|
-
end
|
42
|
-
</pre>
|
43
|
-
|
44
|
-
To specify table name use:
|
45
|
-
|
46
|
-
<pre>
|
47
|
-
rails g i18n:active_record:install MyTranslation
|
48
|
-
</pre>
|
49
|
-
|
50
|
-
With the translation model you will be able to manage your translation, and add new translations or languages through
|
51
|
-
it.
|
52
|
-
|
53
|
-
By default the installer creates a new file in *config/initializers* named *i18n_active_record.rb* with the following content.
|
54
|
-
|
55
|
-
<pre>
|
56
|
-
require 'i18n/backend/active_record'
|
57
|
-
|
58
|
-
Translation = I18n::Backend::ActiveRecord::Translation
|
59
|
-
|
60
|
-
if Translation.table_exists?
|
61
|
-
I18n.backend = I18n::Backend::ActiveRecord.new
|
62
|
-
|
63
|
-
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
|
64
|
-
I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
|
65
|
-
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
|
66
|
-
|
67
|
-
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
|
68
|
-
end
|
69
|
-
</pre>
|
70
|
-
|
71
|
-
To perform a simpler installation use:
|
72
|
-
|
73
|
-
<pre>
|
74
|
-
rails g i18n:active_record:install --simple
|
75
|
-
</pre>
|
76
|
-
|
77
|
-
It generates:
|
78
|
-
|
79
|
-
<pre>
|
80
|
-
require 'i18n/backend/active_record'
|
81
|
-
I18n.backend = I18n::Backend::ActiveRecord.new
|
82
|
-
</pre>
|
83
|
-
|
84
|
-
You may also configure whether the ActiveRecord backend should use @destroy@ or @delete@ when cleaning up internally.
|
85
|
-
|
86
|
-
<pre>
|
87
|
-
I18n::Backend::ActiveRecord.configure do |config|
|
88
|
-
config.cleanup_with_destroy = true # defaults to false
|
89
|
-
end
|
90
|
-
</pre>
|
91
|
-
|
92
|
-
h2. Usage
|
93
|
-
|
94
|
-
You can now use @I18n.t('Your String')@ to lookup translations in the database.
|
95
|
-
|
96
|
-
h2. Missing Translations -> Interpolations
|
97
|
-
|
98
|
-
The interpolations field in the Translations table is used by I18n::Backend::ActiveRecord::Missing to store the interpolations seen the first time this Translation was requested. This will help translators understand what interpolations to expect, and thus to include when providing the translations.
|
99
|
-
|
100
|
-
The interpolations field is otherwise unused since the "value" in Translation.value is actually used for interpolation during actual translations.
|
101
|
-
|
102
|
-
h2. Examples
|
103
|
-
|
104
|
-
* http://collectiveidea.com/blog/archives/2016/05/31/beyond-yml-files-dynamic-translations/
|
105
|
-
|
106
|
-
h2. Maintainers
|
107
|
-
|
108
|
-
* Sven Fuchs
|
109
|
-
* Tim Masliuchenko
|