embedded_localization 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +23 -15
- data/README.md +15 -12
- data/Rakefile +1 -1
- data/embedded_localization.gemspec +3 -6
- 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
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd7d580c4ee09bcfee5042cb602136f648624872fe79ed40a537eaa651886e1c
|
4
|
+
data.tar.gz: 813164fda35ac65c363e5ad9770772206fe1a14c35193a1ce2ab4f6d46eea236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '095d7057199cbc125a9a3d9a22b7b631d26befd029f6cf141f92ff2429c0e4506b1d1443589556773e470e90ef6ab4822e74cfe200c6f820ee8ecfeda48d4de4'
|
7
|
+
data.tar.gz: acc491dc55b119851478ad65b6fdf754a081f84dc6cfc7021ae83b5c51fbf44d555ec7492e8a693ed9dc9cffb4d3f72f77fac3d915659625658b6af9face38fc
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,22 +1,30 @@
|
|
1
1
|
language: ruby
|
2
2
|
bundler_args: --without development
|
3
|
-
|
4
|
-
-
|
5
|
-
-
|
6
|
-
|
7
|
-
- 2.4.2
|
8
|
-
- ruby-head
|
9
|
-
- jruby-head
|
10
|
-
- rbx
|
11
|
-
- ree
|
12
|
-
env: JRUBY_OPTS="--server -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -J-Xms512m -J-Xmx1024m"
|
3
|
+
before_install:
|
4
|
+
- gem install bundler
|
5
|
+
- gem update --system
|
6
|
+
|
13
7
|
matrix:
|
14
|
-
|
15
|
-
-
|
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"
|
16
26
|
- rvm: ruby-head
|
17
|
-
|
18
|
-
- rvm: ree
|
19
|
-
- rvm: jruby-19mode
|
27
|
+
|
20
28
|
branches:
|
21
29
|
only:
|
22
30
|
- master
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
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
|
-
`embedded_localization` is compatible with Rails 3 and Rails
|
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
|
|
@@ -301,14 +312,6 @@ For a new empty record, this will be empty.
|
|
301
312
|
g.set_localized_attribute(:name, :de, "Science-Fiction")
|
302
313
|
# => "Science-Fiction"
|
303
314
|
|
304
|
-
## Motivation
|
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.
|
309
|
-
|
310
|
-
If your requirements are different, my approach might not work for you. In that case, I recommend to look at the alternative solutions listed below.
|
311
|
-
|
312
315
|
## Changes
|
313
316
|
|
314
317
|
### 1.2.0 (2017-11-10)
|
@@ -358,7 +361,7 @@ If your requirements are different, my approach might not work for you. In that
|
|
358
361
|
## Alternative Solutions
|
359
362
|
|
360
363
|
* [Mongoid](https://github.com/mongoid/mongoid) - awesome Ruby ORM for MongoDB, which includes in-table localization of attributes (mongoid >= 2.3.0)
|
361
|
-
* [
|
364
|
+
* [Globalize](https://github.com/globalize/globalize) - is an awesome gem, but different approach with more tables in the schema.
|
362
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
|
363
366
|
* [TranslatableColumns](http://github.com/iain/translatable_columns) - have multiple languages of the same attribute in a model (Iain Hecker)
|
364
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
@@ -8,11 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Tilo Sloboda"]
|
9
9
|
s.email = ["tilo.sloboda@gmail.com"]
|
10
10
|
s.homepage = "https://github.com/tilo/embedded_localization"
|
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]"
|
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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embedded_localization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Sloboda
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '5.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '5.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: 'Rails I18n: Embedded_Localization for ActiveRecord
|
69
|
+
description: 'Rails I18n: Embedded_Localization for ActiveRecord is very lightweight,
|
70
70
|
and allows you to transparently store translations of attributes right inside each
|
71
71
|
record -- no extra database tables needed to store the localization data!'
|
72
72
|
email:
|
@@ -99,7 +99,7 @@ licenses:
|
|
99
99
|
- MIT
|
100
100
|
- GPL-2
|
101
101
|
metadata: {}
|
102
|
-
post_install_message:
|
102
|
+
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
@@ -114,11 +114,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
|
118
|
-
|
119
|
-
signing_key:
|
117
|
+
rubygems_version: 3.1.6
|
118
|
+
signing_key:
|
120
119
|
specification_version: 4
|
121
|
-
summary: 'Rails I18n: library for embedded ActiveRecord
|
120
|
+
summary: 'Rails I18n: library for embedded ActiveRecord model/data translation'
|
122
121
|
test_files:
|
123
122
|
- spec/embedded_localization/native_column_spec.rb
|
124
123
|
- spec/embedded_localization/simple_model_spec.rb
|