embedded_localization 1.1.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +23 -14
- data/Gemfile +2 -2
- data/README.md +59 -48
- data/Rakefile +1 -1
- data/embedded_localization.gemspec +4 -7
- data/lib/embedded_localization/active_record/act_macro.rb +2 -2
- data/lib/embedded_localization/version.rb +1 -1
- data/lib/extensions/hash.rb +1 -1
- data/spec/embedded_localization/native_column_spec.rb +14 -7
- data/spec/embedded_localization/simple_model_spec.rb +14 -6
- data/spec/spec_helper.rb +11 -2
- metadata +25 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd7d580c4ee09bcfee5042cb602136f648624872fe79ed40a537eaa651886e1c
|
4
|
+
data.tar.gz: 813164fda35ac65c363e5ad9770772206fe1a14c35193a1ce2ab4f6d46eea236
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '095d7057199cbc125a9a3d9a22b7b631d26befd029f6cf141f92ff2429c0e4506b1d1443589556773e470e90ef6ab4822e74cfe200c6f820ee8ecfeda48d4de4'
|
7
|
+
data.tar.gz: acc491dc55b119851478ad65b6fdf754a081f84dc6cfc7021ae83b5c51fbf44d555ec7492e8a693ed9dc9cffb4d3f72f77fac3d915659625658b6af9face38fc
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
language: ruby
|
2
2
|
bundler_args: --without development
|
3
|
-
|
4
|
-
-
|
5
|
-
-
|
6
|
-
|
7
|
-
- 2.0.0
|
8
|
-
- ruby-head
|
9
|
-
- ree
|
3
|
+
before_install:
|
4
|
+
- gem install bundler
|
5
|
+
- gem update --system
|
6
|
+
|
10
7
|
matrix:
|
11
|
-
|
12
|
-
-
|
13
|
-
-
|
8
|
+
include:
|
9
|
+
- rvm: 2.2.10
|
10
|
+
- rvm: 2.3.8
|
11
|
+
- rvm: 2.4.10
|
12
|
+
- rvm: 2.5.8
|
13
|
+
- rvm: 2.6.9
|
14
|
+
- rvm: 2.7.5
|
15
|
+
- rvm: 3.0.3
|
16
|
+
- rvm: 3.1.0
|
17
|
+
- rvm: jruby-9.2.19.0
|
18
|
+
- rvm: jruby-9.3.3.0
|
19
|
+
- jruby-head
|
20
|
+
- mruby
|
21
|
+
- rubinius
|
22
|
+
- ree
|
23
|
+
|
24
|
+
env:
|
25
|
+
- JRUBY_OPTS="--server -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -J-Xms512m -J-Xmx1024m"
|
14
26
|
- rvm: ruby-head
|
15
|
-
|
16
|
-
- rvm: 1.8.7
|
17
|
-
- rvm: 1.9.2
|
18
|
-
- rvm: rbx-18mode
|
27
|
+
|
19
28
|
branches:
|
20
29
|
only:
|
21
30
|
- master
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Embedded Localization
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/tilo/embedded_localization.png?branch=master)](http://travis-ci.org/tilo/
|
3
|
+
[![Build Status](https://secure.travis-ci.org/tilo/embedded_localization.png?branch=master)](http://travis-ci.org/tilo/embedded_localization) [![Gem Version](https://badge.fury.io/rb/embedded_localization.svg)](http://badge.fury.io/rb/embedded_localization)
|
4
4
|
|
5
|
-
`
|
5
|
+
`embedded_localization` is compatible with Rails 3.x, 4.x and Rails 5.x, and adds model translations to ActiveRecord. `embedded_localization` is compatible with and builds on the new [I18n API in Ruby on Rails](http://guides.rubyonrails.org/i18n.html)
|
6
6
|
|
7
7
|
`embedded_localization` is very lightweight, and allows you to transparently store translations of attributes right inside each record — no extra database tables needed to store the localization data! Make sure that your database default encoding is UTF-8 or UFT-16.
|
8
8
|
|
@@ -11,10 +11,21 @@ Model translations with `embedded_localization` use default ActiveRecord feature
|
|
11
11
|
On top of that, you also get tools for checking into which locales an attribute was translated to, as well as for checking overall translation coverage.
|
12
12
|
|
13
13
|
|
14
|
+
## Motivation
|
15
|
+
|
16
|
+
One real-life scenario is that you have a SaaS system which needs custom text for each company, which also needs to be translated in to several languages. Another scenario is that you have dynamic content that needs to be translated.
|
17
|
+
|
18
|
+
A recent project needed some localization support for ActiveRecord model data, but I did not want to clutter the schema with one additional table for each translated model, as the globalize gem requires. A second requirement was to allow SQL queries of the fields using the default locale.
|
19
|
+
|
20
|
+
The advantage of EmbeddedLocalization is that it does not need extra tables, and therefore no joins or additional table lookups to get to the translated data.
|
21
|
+
|
22
|
+
If your requirements are different, this approach might not work for you. In that case, I recommend to look at the alternative solutions listed at the bottom of this page.
|
23
|
+
|
24
|
+
|
14
25
|
## Requirements
|
15
26
|
|
16
|
-
* ActiveRecord
|
17
|
-
* I18n
|
27
|
+
* ActiveRecord >= 3
|
28
|
+
* [I18n](http://guides.rubyonrails.org/i18n.html)
|
18
29
|
|
19
30
|
## Installation
|
20
31
|
|
@@ -47,14 +58,14 @@ In the DB migration, you just need to add the `i18n` text field:
|
|
47
58
|
t.text :i18n # stores ALL the translated attributes; persisted as a Hash
|
48
59
|
|
49
60
|
t.timestamps
|
50
|
-
end
|
61
|
+
end
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
54
65
|
### Example 2
|
55
66
|
|
56
67
|
Obviously you can't do SQL queries against tanslated fields which are stored in the `i18n` text field.
|
57
|
-
To eliviate this problem, you can also define a normal DB attribute with the same name as your translated attribute, and it will store the value for your `I18n.default_locale`.
|
68
|
+
To eliviate this problem, you can also define a normal DB attribute with the same name as your translated attribute, and it will store the value for your `I18n.default_locale`.
|
58
69
|
|
59
70
|
This way you can always do SQL queries against the values in the `I18n.default_locale`.
|
60
71
|
|
@@ -66,9 +77,9 @@ To do this, using the same model as in example 1, you can modify your migration
|
|
66
77
|
t.text :i18n # stores the translated attributes; persisted as a Hash
|
67
78
|
|
68
79
|
t.string :name # allows us to do SQL queries
|
69
|
-
|
80
|
+
|
70
81
|
t.timestamps
|
71
|
-
end
|
82
|
+
end
|
72
83
|
end
|
73
84
|
end
|
74
85
|
|
@@ -78,25 +89,25 @@ In your code you can modify the values of your translated attributes in two ways
|
|
78
89
|
|
79
90
|
## Using Setters / Getters
|
80
91
|
|
81
|
-
Using the built-in getter/setter methods you can set the values for any locale directly, even though
|
92
|
+
Using the built-in getter/setter methods you can set the values for any locale directly, even though
|
82
93
|
you are using your own locale.
|
83
94
|
|
84
95
|
I18n.locale = :en
|
85
96
|
g = Genre.first
|
86
|
-
g.name = 'science fiction'
|
87
|
-
|
97
|
+
g.name = 'science fiction'
|
98
|
+
|
88
99
|
# even though you are using the :en locale, you can still set the values for other locales:
|
89
|
-
|
100
|
+
|
90
101
|
g.set_localized_attribute( :name, :jp, "サイエンスフィクション" )
|
91
102
|
g.set_localized_attribute( :name, :ko, "공상 과학 소설" )
|
92
|
-
|
103
|
+
|
93
104
|
g.name # => 'science fiction'
|
94
105
|
g.name(:jp) # => "サイエンスフィクション"
|
95
106
|
g.name(:ko) # => "공상 과학 소설"
|
96
|
-
|
107
|
+
|
97
108
|
g.get_localized_attribute( :name, :jp ) # => "サイエンスフィクション"
|
98
109
|
g.get_localized_attribute( :name, :ko ) # => "공상 과학 소설"
|
99
|
-
|
110
|
+
|
100
111
|
## Tweaking `I18n.locale`
|
101
112
|
|
102
113
|
By manipulating the `I18n.locale`. This is what happens if you have user's with different locales entering values into a database.
|
@@ -106,31 +117,31 @@ By manipulating the `I18n.locale`. This is what happens if you have user's with
|
|
106
117
|
I18n.locale = :en
|
107
118
|
g = Genre.first
|
108
119
|
g.name # => 'science fiction'
|
109
|
-
|
120
|
+
|
110
121
|
I18n.locale = :jp
|
111
122
|
g.name = "サイエンスフィクション"
|
112
|
-
|
123
|
+
|
113
124
|
I18n.locale = :ko
|
114
125
|
g.name = "공상 과학 소설"
|
115
126
|
g.name # => "공상 과학 소설"
|
116
|
-
|
127
|
+
|
117
128
|
I18n.locale = :jp
|
118
129
|
g.name # => "サイエンスフィクション"
|
119
|
-
|
130
|
+
|
120
131
|
I18n.locale = :en # MAKE SURE to switch back to your default locale if you tweak it
|
121
|
-
|
122
|
-
|
132
|
+
|
133
|
+
|
123
134
|
## SQL Queries against Translated Fields
|
124
135
|
|
125
136
|
Old `embedded_localization` implementations < 0.2.0 had the drawback that you can not do SQL queries on translated attributes.
|
126
137
|
|
127
|
-
To eliminate this limitation, you can now define any translated attribute as a first-class database column in your migration.
|
138
|
+
To eliminate this limitation, you can now define any translated attribute as a first-class database column in your migration.
|
128
139
|
|
129
|
-
If you define a translated attribute as a column, `embedded_localization` will store the attribute value for I18n.default_locale in that column, so you can search for it.
|
140
|
+
If you define a translated attribute as a column, `embedded_localization` will store the attribute value for I18n.default_locale in that column, so you can search for it.
|
130
141
|
|
131
142
|
After defining the column, and running the migration, you need to populate the column initially. It will auto-update every time you write while you are using I18n.default_locale .
|
132
143
|
|
133
|
-
See also Example 2 above.
|
144
|
+
See also Example 2 above.
|
134
145
|
|
135
146
|
I18n.locale = :en
|
136
147
|
g = Genre.first
|
@@ -215,17 +226,17 @@ Each model instance of a class which uses `embedded_localization` will have thes
|
|
215
226
|
* hash of translation coverage for a given record's attributes or a particular attribute
|
216
227
|
* hash of missing translations for a given record's attributes or a particular attribute
|
217
228
|
* directly setting and getting attribute values for a given locale; without having to change `I18n.locale`
|
218
|
-
|
229
|
+
|
219
230
|
e.g.:
|
220
231
|
|
221
232
|
g = Genre.where(:name => "science fiction").first
|
222
|
-
|
233
|
+
|
223
234
|
# check if an attribute is translated:
|
224
235
|
g.translated?(:name) # => true
|
225
|
-
|
236
|
+
|
226
237
|
# which attributes are translated?
|
227
238
|
g.translated_attributes # => [:description, :name]
|
228
|
-
|
239
|
+
|
229
240
|
# check for which locales we have values: (spanning all translated fields)
|
230
241
|
g.translated_locales # => [:en]
|
231
242
|
|
@@ -237,13 +248,13 @@ e.g.:
|
|
237
248
|
# show details for which locales the attributes have values for:
|
238
249
|
# for all attributes:
|
239
250
|
g.translation_coverage # => {:name=>[:en], :description=>[:de]}
|
240
|
-
|
241
|
-
# for a specific attribute:
|
251
|
+
|
252
|
+
# for a specific attribute:
|
242
253
|
g.translation_coverage(:name) # => [:en]
|
243
254
|
g.translation_coverage(:description) # => [:de]
|
244
255
|
|
245
256
|
# show where translations are missing:
|
246
|
-
# for all attributes:
|
257
|
+
# for all attributes:
|
247
258
|
g.translation_missing # => {:description=>[:en], :name=>[:de]}
|
248
259
|
|
249
260
|
# for a specific attribute:
|
@@ -251,7 +262,7 @@ e.g.:
|
|
251
262
|
g.translation_missing(:description) # => [:en]
|
252
263
|
|
253
264
|
|
254
|
-
|
265
|
+
|
255
266
|
|
256
267
|
#### translated_locales vs translation_coverage
|
257
268
|
|
@@ -274,42 +285,42 @@ For a new empty record, this will be empty.
|
|
274
285
|
I18n.locale = :jp
|
275
286
|
g = Genre.first
|
276
287
|
g.name # => "サイエンスフィクション"
|
277
|
-
|
288
|
+
|
278
289
|
g.name(:en) # => 'science fiction'
|
279
290
|
g.name(:ko) # => "공상 과학 소설"
|
280
291
|
g.name(:de) # => nil
|
281
|
-
|
292
|
+
|
282
293
|
g.translated_locales # => [:en,:jp,:ko]
|
283
294
|
g.translated_attributes # => [:name,:description]
|
284
295
|
g.translated? # => true
|
285
|
-
|
296
|
+
|
286
297
|
g.translation_coverage
|
287
298
|
# => {"name"=>["en", "ko", "jp"] , "description"=>["en", "de", "fr", "ko", "jp", "es"]}
|
288
|
-
|
299
|
+
|
289
300
|
g.translation_coverage(:name)
|
290
301
|
# => {"name"=>["en", "ko", "jp"]}
|
291
|
-
|
302
|
+
|
292
303
|
g.translation_missing
|
293
304
|
# => {"name"=>["de", "fr", "es"]}
|
294
|
-
|
305
|
+
|
295
306
|
g.translation_missing(:display)
|
296
307
|
# => {} # this indicates that there are no missing translations for the :display attribute
|
297
|
-
|
308
|
+
|
298
309
|
g.get_localized_attribute(:name, :de)
|
299
310
|
# => nil
|
300
|
-
|
311
|
+
|
301
312
|
g.set_localized_attribute(:name, :de, "Science-Fiction")
|
302
313
|
# => "Science-Fiction"
|
303
314
|
|
304
|
-
##
|
305
|
-
|
306
|
-
A recent project needed some localization support for ActiveRecord model data, but I did not want to clutter the schema with one additional table for each translated model, as globalization3 requires. A second requirement was to allow SQL queries of the fields using the default locale.
|
307
|
-
|
308
|
-
The advantage of EmbeddedLocalization is that it does not need extra tables, and therefore no joins or additional table lookups to get to the translated data.
|
315
|
+
## Changes
|
309
316
|
|
310
|
-
|
317
|
+
### 1.2.0 (2017-11-10)
|
318
|
+
* Rails 5 compatibility
|
319
|
+
* fixing tests
|
320
|
+
* updating doc
|
311
321
|
|
312
|
-
|
322
|
+
### 1.1.1 (2014-11-02)
|
323
|
+
* minor update
|
313
324
|
|
314
325
|
### 1.1.0 (2014-01-12)
|
315
326
|
* adding more rspec tests.
|
@@ -350,7 +361,7 @@ If your requirements are different, my approach might not work for you. In that
|
|
350
361
|
## Alternative Solutions
|
351
362
|
|
352
363
|
* [Mongoid](https://github.com/mongoid/mongoid) - awesome Ruby ORM for MongoDB, which includes in-table localization of attributes (mongoid >= 2.3.0)
|
353
|
-
* [
|
364
|
+
* [Globalize](https://github.com/globalize/globalize) - is an awesome gem, but different approach with more tables in the schema.
|
354
365
|
* [Veger's fork of Globalize2](http://github.com/veger/globalize2) - uses default AR schema for the default locale, delegates to the translations table for other locales only
|
355
366
|
* [TranslatableColumns](http://github.com/iain/translatable_columns) - have multiple languages of the same attribute in a model (Iain Hecker)
|
356
367
|
* [localized_record](http://github.com/glennpow/localized_record) - allows records to have localized attributes without any modifications to the database (Glenn Powell)
|
data/Rakefile
CHANGED
@@ -7,12 +7,9 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = EmbeddedLocalization::VERSION
|
8
8
|
s.authors = ["Tilo Sloboda"]
|
9
9
|
s.email = ["tilo.sloboda@gmail.com"]
|
10
|
-
s.homepage = "
|
11
|
-
s.summary = %q{Rails I18n: library for embedded ActiveRecord
|
12
|
-
s.description = %q{Rails I18n: Embedded_Localization for ActiveRecord
|
13
|
-
|
14
|
-
# s.rubyforge_project = "embedded_localization"
|
15
|
-
s.rubyforge_project = "[none]"
|
10
|
+
s.homepage = "https://github.com/tilo/embedded_localization"
|
11
|
+
s.summary = %q{Rails I18n: library for embedded ActiveRecord model/data translation}
|
12
|
+
s.description = %q{Rails I18n: Embedded_Localization for ActiveRecord is very lightweight, and allows you to transparently store translations of attributes right inside each record -- no extra database tables needed to store the localization data!}
|
16
13
|
|
17
14
|
# s.platform = Gem::Platform::RUBY
|
18
15
|
|
@@ -23,7 +20,7 @@ Gem::Specification.new do |s|
|
|
23
20
|
s.licenses = ['MIT','GPL-2']
|
24
21
|
# specify any dependencies here; for example:
|
25
22
|
s.add_development_dependency "rspec"
|
26
|
-
s.add_development_dependency "activerecord", "~>
|
23
|
+
s.add_development_dependency "activerecord", "~> 5.1"
|
27
24
|
s.add_development_dependency "i18n"
|
28
25
|
s.add_development_dependency "sqlite3"
|
29
26
|
# s.add_runtime_dependency "rest-client"
|
@@ -5,8 +5,8 @@ module EmbeddedLocalization
|
|
5
5
|
return if translates? # cludge to make sure we don't set this up twice..
|
6
6
|
|
7
7
|
# for details about I18n fallbacks, check the source:
|
8
|
-
# i18n-0.
|
9
|
-
# i18n-0.
|
8
|
+
# i18n-0.9.0/lib/i18n/backend/fallbacks.rb
|
9
|
+
# i18n-0.9.0/lib/i18n/locale/fallbacks.rb
|
10
10
|
|
11
11
|
# options[:fallbacks] => true or false # not used at this time
|
12
12
|
options = attr_names.extract_options!
|
data/lib/extensions/hash.rb
CHANGED
@@ -9,11 +9,10 @@ I18n.locale = :en
|
|
9
9
|
describe 'model has translated field with attribute of that same name' do
|
10
10
|
let(:movie){ Movie.new }
|
11
11
|
|
12
|
-
|
13
12
|
describe "basic things that need to work" do
|
14
13
|
|
15
14
|
it 'reports it translates' do
|
16
|
-
Movie.translates?.should
|
15
|
+
Movie.translates?.should be_truthy
|
17
16
|
end
|
18
17
|
|
19
18
|
it 'correctly reports the list of translated_attributes' do
|
@@ -25,12 +24,12 @@ describe 'model has translated field with attribute of that same name' do
|
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'correcty shows the translated attribute as translated' do
|
28
|
-
Movie.translated?(:title).should
|
29
|
-
Movie.translated?(:description).should
|
27
|
+
Movie.translated?(:title).should be_truthy
|
28
|
+
Movie.translated?(:description).should be_truthy
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'correcty shows not translated attribute' do
|
33
|
-
Movie.translated?(:other).should
|
32
|
+
Movie.translated?(:other).should be_falsy
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
@@ -41,7 +40,7 @@ describe 'model has translated field with attribute of that same name' do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
it 'correctly reports translation_missing for new record' do
|
44
|
-
movie.translation_missing.should
|
43
|
+
movie.translation_missing.should be_truthy
|
45
44
|
end
|
46
45
|
|
47
46
|
it 'creates the accessor methods' do
|
@@ -109,6 +108,10 @@ describe 'model has translated field with attribute of that same name' do
|
|
109
108
|
movie.reload
|
110
109
|
end
|
111
110
|
|
111
|
+
it 'correctly reports the translated_locales' do
|
112
|
+
movie.translated_locales.should eq [:en]
|
113
|
+
end
|
114
|
+
|
112
115
|
# when setting all fields in the default locale's languange:
|
113
116
|
it 'correctly reports translation_missing for updated record' do
|
114
117
|
movie.translation_missing.should eq Hash.new
|
@@ -143,9 +146,13 @@ describe 'model has translated field with attribute of that same name' do
|
|
143
146
|
movie.reload
|
144
147
|
end
|
145
148
|
|
149
|
+
it 'correctly reports the translated_locales' do
|
150
|
+
movie.translated_locales.should eq [:en, :ru, :tr, :de]
|
151
|
+
end
|
152
|
+
|
146
153
|
it 'can assign the translated field' do
|
147
154
|
movie.title = title_en
|
148
|
-
movie.save.should
|
155
|
+
movie.save.should be_truthy
|
149
156
|
movie.title.should eq title_en
|
150
157
|
movie.title(:en).should eq title_en
|
151
158
|
end
|
@@ -13,7 +13,7 @@ describe 'model has translated field without attribute of that same name' do
|
|
13
13
|
describe "basic things that need to work" do
|
14
14
|
|
15
15
|
it 'reports it translates' do
|
16
|
-
Genre.translates?.should
|
16
|
+
Genre.translates?.should be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'correctly reports the list of translated_attributes' do
|
@@ -25,12 +25,12 @@ describe 'model has translated field without attribute of that same name' do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'correcty shows the translated attribute as translated' do
|
28
|
-
Genre.translated?(:name).should
|
29
|
-
Genre.translated?(:description).should
|
28
|
+
Genre.translated?(:name).should be_truthy
|
29
|
+
Genre.translated?(:description).should be_truthy
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'correcty shows not translated attribute' do
|
33
|
-
Genre.translated?(:other).should
|
33
|
+
Genre.translated?(:other).should be_falsy
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ describe 'model has translated field without attribute of that same name' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'correctly reports translation_missing for new record' do
|
44
|
-
genre.translation_missing.should
|
44
|
+
genre.translation_missing.should be_truthy
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'creates the accessor methods' do
|
@@ -106,6 +106,10 @@ describe 'model has translated field without attribute of that same name' do
|
|
106
106
|
genre.reload
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'correctly reports the translated_locales' do
|
110
|
+
genre.translated_locales.should eq [:en]
|
111
|
+
end
|
112
|
+
|
109
113
|
# when setting all fields in the default locale's languange:
|
110
114
|
it 'correctly reports translation_missing for updated record' do
|
111
115
|
genre.translation_missing.should eq Hash.new
|
@@ -141,9 +145,13 @@ describe 'model has translated field without attribute of that same name' do
|
|
141
145
|
genre.reload
|
142
146
|
end
|
143
147
|
|
148
|
+
it 'correctly reports the translated_locales' do
|
149
|
+
genre.translated_locales.should eq [:en, :jp, :ko, :de]
|
150
|
+
end
|
151
|
+
|
144
152
|
it 'can assign the translated field' do
|
145
153
|
genre.name = genre_name_en
|
146
|
-
genre.save.should
|
154
|
+
genre.save.should be_truthy
|
147
155
|
genre.name.should eq genre_name_en
|
148
156
|
genre.name(:en).should eq genre_name_en
|
149
157
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,8 +13,17 @@ load File.dirname(__FILE__) + '/schema.rb'
|
|
13
13
|
require File.dirname(__FILE__) + '/models.rb'
|
14
14
|
|
15
15
|
|
16
|
+
I18n.enforce_available_locales = false
|
17
|
+
I18n.config.available_locales = [:ru,:jp,:ko,:fr,:en,:de]
|
18
|
+
|
16
19
|
RSpec.configure do |config|
|
17
|
-
config.
|
18
|
-
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
expectations.syntax = :should
|
22
|
+
end
|
23
|
+
config.mock_with :rspec do |mocks|
|
24
|
+
mocks.syntax = :should
|
25
|
+
end
|
26
|
+
|
27
|
+
config.filter_run_including :focus => true
|
19
28
|
config.run_all_when_everything_filtered = true
|
20
29
|
end
|
metadata
CHANGED
@@ -1,81 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embedded_localization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tilo Sloboda
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activerecord
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '5.1'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '5.1'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: i18n
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: sqlite3
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
|
-
description:
|
69
|
+
description: 'Rails I18n: Embedded_Localization for ActiveRecord is very lightweight,
|
79
70
|
and allows you to transparently store translations of attributes right inside each
|
80
71
|
record -- no extra database tables needed to store the localization data!'
|
81
72
|
email:
|
@@ -84,8 +75,8 @@ executables: []
|
|
84
75
|
extensions: []
|
85
76
|
extra_rdoc_files: []
|
86
77
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .travis.yml
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
89
80
|
- Gemfile
|
90
81
|
- README.md
|
91
82
|
- Rakefile
|
@@ -103,32 +94,30 @@ files:
|
|
103
94
|
- spec/schema.rb
|
104
95
|
- spec/spec.opts
|
105
96
|
- spec/spec_helper.rb
|
106
|
-
homepage:
|
97
|
+
homepage: https://github.com/tilo/embedded_localization
|
107
98
|
licenses:
|
108
99
|
- MIT
|
109
100
|
- GPL-2
|
110
|
-
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
111
103
|
rdoc_options: []
|
112
104
|
require_paths:
|
113
105
|
- lib
|
114
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
107
|
requirements:
|
117
|
-
- -
|
108
|
+
- - ">="
|
118
109
|
- !ruby/object:Gem::Version
|
119
110
|
version: '0'
|
120
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
112
|
requirements:
|
123
|
-
- -
|
113
|
+
- - ">="
|
124
114
|
- !ruby/object:Gem::Version
|
125
115
|
version: '0'
|
126
116
|
requirements: []
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
summary: ! 'Rails I18n: library for embedded ActiveRecord 3 model/data translation'
|
117
|
+
rubygems_version: 3.1.6
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: 'Rails I18n: library for embedded ActiveRecord model/data translation'
|
132
121
|
test_files:
|
133
122
|
- spec/embedded_localization/native_column_spec.rb
|
134
123
|
- spec/embedded_localization/simple_model_spec.rb
|