globalize 5.0.1 → 5.2.0
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 +5 -5
- data/Appraisals +33 -0
- data/CHANGELOG.md +12 -0
- data/CONTRIBUTING.md +15 -0
- data/Gemfile +0 -9
- data/Gemfile.lock +59 -241
- data/{readme.md → README.md} +124 -36
- data/Rakefile +33 -0
- data/lib/globalize/active_record/act_macro.rb +27 -1
- data/lib/globalize/active_record/adapter.rb +13 -5
- data/lib/globalize/active_record/adapter_dirty.rb +56 -0
- data/lib/globalize/active_record/class_methods.rb +23 -9
- data/lib/globalize/active_record/exceptions.rb +1 -7
- data/lib/globalize/active_record/instance_methods.rb +89 -41
- data/lib/globalize/active_record/migration.rb +58 -31
- data/lib/globalize/active_record/translated_attributes_query.rb +181 -0
- data/lib/globalize/active_record.rb +10 -9
- data/lib/globalize/version.rb +1 -1
- data/lib/globalize.rb +20 -6
- data/lib/patches/active_record/persistence.rb +6 -15
- data/lib/patches/active_record/query_method.rb +2 -34
- data/lib/patches/active_record/rails4/query_method.rb +35 -0
- data/lib/patches/active_record/rails4/serialization.rb +22 -0
- data/lib/patches/active_record/rails4/uniqueness_validator.rb +42 -0
- data/lib/patches/active_record/rails5/uniqueness_validator.rb +47 -0
- data/lib/patches/active_record/rails5_1/serialization.rb +22 -0
- data/lib/patches/active_record/rails5_1/uniqueness_validator.rb +45 -0
- data/lib/patches/active_record/relation.rb +12 -0
- data/lib/patches/active_record/serialization.rb +5 -24
- data/lib/patches/active_record/uniqueness_validator.rb +7 -39
- data/lib/patches/active_record/xml_attribute_serializer.rb +19 -9
- metadata +85 -22
- data/globalize.gemspec +0 -29
- data/lib/globalize/active_record/query_methods.rb +0 -98
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 18d470a9030a9901a83b9d3c48080661b10000a20049f598eece0b41727d66dc
|
|
4
|
+
data.tar.gz: b1ea4e1d1c0210271fede3bf8d7903ac658ace1af1742bf29980139efc555673
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70eaedf3edada661ab9495f31ec46544cc950ba4c6ff667c9d6e1bf699cd770de02ffab2783ba29735c39d35d6b92c9ab2b0f8061185a3e1f3469354f82e560a
|
|
7
|
+
data.tar.gz: 1b255c9f3164165e76650a4b0fbbfbc989f87ec524a9c4bb1e70ea8fd54b3f16811a9c5a42cfe8f38df0d47ca00fd2632a95f0918c58bdb2e24b5c313b5d2508
|
data/Appraisals
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RAILS_VERSIONS = %w[
|
|
4
|
+
4.2.10
|
|
5
|
+
5.1.6
|
|
6
|
+
5.2.1
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
RAILS_VERSIONS.each do |version|
|
|
10
|
+
appraise "rails_#{version}" do
|
|
11
|
+
gem 'activemodel', version
|
|
12
|
+
gem 'activerecord', version
|
|
13
|
+
|
|
14
|
+
platforms :rbx do
|
|
15
|
+
gem "rubysl", "~> 2.0"
|
|
16
|
+
gem "rubinius-developer_tools"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
platforms :jruby do
|
|
20
|
+
if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
|
|
21
|
+
gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
|
|
25
|
+
gem 'activerecord-jdbcmysql-adapter', '~> 1'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
|
|
29
|
+
gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Globalize Changelog
|
|
2
2
|
|
|
3
|
+
## 5.1.0 (2018-01-15)
|
|
4
|
+
|
|
5
|
+
* Replaced `after_` callbacks with `before_` callbacks and set `autosave: true` by default. [#341](https://github.com/globalize/globalize/pull/341) by [Andrew Volozhanin](https://github.com/scarfacedeb)
|
|
6
|
+
* Add [RequestStore](https://github.com/steveklabnik/request_store) to make Globalize thread-safe again [#420](https://github.com/globalize/globalize/pull/420)
|
|
7
|
+
* Join the translations table when ordering by translated attributes (https://github.com/globalize/globalize/pull/447). (thanks [Thomas Maas](https://github.com/thomasmaas) & [Michal Cichra](https://github.com/mikz)).
|
|
8
|
+
* Add `unique` to `with_translation` to prevent duplicates if fallbacks are defined and the queried locale is not the fallback language. [#489](https://github.com/globalize/globalize/pull/489) by [krisdigital](https://github.com/krisdigital)
|
|
9
|
+
|
|
3
10
|
## 5.0.1 (2015-02-15)
|
|
4
11
|
|
|
5
12
|
* Don't touch table when model is loaded. [#412](https://github.com/globalize/globalize/pull/412)
|
|
@@ -74,7 +81,12 @@
|
|
|
74
81
|
|
|
75
82
|
* Backport scope support on uniqueness validation from 4.0, drop support for ActiveRecord < 3.1, fixes [#324](https://github.com/globalize/globalize/issues/324).
|
|
76
83
|
|
|
84
|
+
## 3.0.5 (2015-04-24)
|
|
85
|
+
|
|
86
|
+
* Now working properly with the squeel library. (thanks [Toru Mori](https://github.com/torumori)). See [#437](https://github.com/globalize/globalize/pull/437)
|
|
87
|
+
|
|
77
88
|
## 3.0.4 (2014-01-08)
|
|
89
|
+
|
|
78
90
|
* Extract all versioning-related code to separate [globalize-versioning](https://github.com/globalize/globalize-versioning) gem.
|
|
79
91
|
|
|
80
92
|
## 3.0.3 (2013-12-26)
|
data/CONTRIBUTING.md
CHANGED
|
@@ -35,3 +35,18 @@ Have a bug fix, code improvement or proposed feature? Do the following:
|
|
|
35
35
|
For pull requests to Rails/ActiveRecord 4 version of Globalize (v3.x), post to the `master` branch. For pull requests to the Rails/ActiveRecord 3.x version of Globalize (3.x), post to the `3-0-stable` branch.
|
|
36
36
|
|
|
37
37
|
When you submit the pull request, Travis CI will run the [test suite](https://travis-ci.org/globalize/globalize) against your branch and will highlight any failures. Unless there is a good reason for it, we do not generally accept pull requests that take Globalize from green to red.
|
|
38
|
+
|
|
39
|
+
## Testing
|
|
40
|
+
|
|
41
|
+
### Requirements
|
|
42
|
+
|
|
43
|
+
- Ruby
|
|
44
|
+
- Bundler
|
|
45
|
+
- SQLite
|
|
46
|
+
- You can switch the database by adding an environment variable. See `test/support/database.rb`.
|
|
47
|
+
- You can also configure your database configurations. See `test/support/database.yml`.
|
|
48
|
+
|
|
49
|
+
### Run tests on your local machine
|
|
50
|
+
|
|
51
|
+
- `bundle install`
|
|
52
|
+
- `bundle exec rake`
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,268 +1,86 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
globalize (5.0
|
|
5
|
-
activemodel (>= 4.2
|
|
6
|
-
activerecord (>= 4.2
|
|
4
|
+
globalize (5.2.0)
|
|
5
|
+
activemodel (>= 4.2, < 5.3)
|
|
6
|
+
activerecord (>= 4.2, < 5.3)
|
|
7
|
+
request_store (~> 1.0)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
10
11
|
specs:
|
|
11
|
-
activemodel (
|
|
12
|
-
activesupport (=
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
i18n (
|
|
20
|
-
json (~> 1.7, >= 1.7.7)
|
|
12
|
+
activemodel (5.2.1)
|
|
13
|
+
activesupport (= 5.2.1)
|
|
14
|
+
activerecord (5.2.1)
|
|
15
|
+
activemodel (= 5.2.1)
|
|
16
|
+
activesupport (= 5.2.1)
|
|
17
|
+
arel (>= 9.0)
|
|
18
|
+
activesupport (5.2.1)
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
i18n (>= 0.7, < 2)
|
|
21
21
|
minitest (~> 5.1)
|
|
22
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
|
23
22
|
tzinfo (~> 1.1)
|
|
24
|
-
ansi (1.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
ansi (1.5.0)
|
|
24
|
+
appraisal (2.2.0)
|
|
25
|
+
bundler
|
|
26
|
+
rake
|
|
27
|
+
thor (>= 0.14.0)
|
|
28
|
+
arel (9.0.0)
|
|
29
|
+
builder (3.2.3)
|
|
30
|
+
coderay (1.1.2)
|
|
31
|
+
concurrent-ruby (1.0.5)
|
|
32
|
+
concurrent-ruby (1.0.5-java)
|
|
33
|
+
database_cleaner (1.6.2)
|
|
34
|
+
ffi (1.9.18-java)
|
|
35
|
+
i18n (1.1.1)
|
|
36
|
+
concurrent-ruby (~> 1.0)
|
|
37
|
+
m (1.5.1)
|
|
38
|
+
method_source (>= 0.6.7)
|
|
39
|
+
rake (>= 0.9.2.2)
|
|
40
|
+
method_source (0.9.0)
|
|
41
|
+
minitest (5.11.1)
|
|
42
|
+
minitest-reporters (1.1.19)
|
|
35
43
|
ansi
|
|
36
44
|
builder
|
|
37
45
|
minitest (>= 5.0)
|
|
38
46
|
ruby-progressbar
|
|
39
|
-
pry (0.
|
|
47
|
+
pry (0.11.3)
|
|
40
48
|
coderay (~> 1.1.0)
|
|
41
|
-
method_source (~> 0.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rubysl-coverage (~> 2.0)
|
|
60
|
-
rubysl-csv (~> 2.0)
|
|
61
|
-
rubysl-curses (~> 2.0)
|
|
62
|
-
rubysl-date (~> 2.0)
|
|
63
|
-
rubysl-delegate (~> 2.0)
|
|
64
|
-
rubysl-digest (~> 2.0)
|
|
65
|
-
rubysl-drb (~> 2.0)
|
|
66
|
-
rubysl-e2mmap (~> 2.0)
|
|
67
|
-
rubysl-english (~> 2.0)
|
|
68
|
-
rubysl-enumerator (~> 2.0)
|
|
69
|
-
rubysl-erb (~> 2.0)
|
|
70
|
-
rubysl-etc (~> 2.0)
|
|
71
|
-
rubysl-expect (~> 2.0)
|
|
72
|
-
rubysl-fcntl (~> 2.0)
|
|
73
|
-
rubysl-fiber (~> 2.0)
|
|
74
|
-
rubysl-fileutils (~> 2.0)
|
|
75
|
-
rubysl-find (~> 2.0)
|
|
76
|
-
rubysl-forwardable (~> 2.0)
|
|
77
|
-
rubysl-getoptlong (~> 2.0)
|
|
78
|
-
rubysl-gserver (~> 2.0)
|
|
79
|
-
rubysl-io-console (~> 2.0)
|
|
80
|
-
rubysl-io-nonblock (~> 2.0)
|
|
81
|
-
rubysl-io-wait (~> 2.0)
|
|
82
|
-
rubysl-ipaddr (~> 2.0)
|
|
83
|
-
rubysl-irb (~> 2.1)
|
|
84
|
-
rubysl-logger (~> 2.0)
|
|
85
|
-
rubysl-mathn (~> 2.0)
|
|
86
|
-
rubysl-matrix (~> 2.0)
|
|
87
|
-
rubysl-mkmf (~> 2.0)
|
|
88
|
-
rubysl-monitor (~> 2.0)
|
|
89
|
-
rubysl-mutex_m (~> 2.0)
|
|
90
|
-
rubysl-net-ftp (~> 2.0)
|
|
91
|
-
rubysl-net-http (~> 2.0)
|
|
92
|
-
rubysl-net-imap (~> 2.0)
|
|
93
|
-
rubysl-net-pop (~> 2.0)
|
|
94
|
-
rubysl-net-protocol (~> 2.0)
|
|
95
|
-
rubysl-net-smtp (~> 2.0)
|
|
96
|
-
rubysl-net-telnet (~> 2.0)
|
|
97
|
-
rubysl-nkf (~> 2.0)
|
|
98
|
-
rubysl-observer (~> 2.0)
|
|
99
|
-
rubysl-open-uri (~> 2.0)
|
|
100
|
-
rubysl-open3 (~> 2.0)
|
|
101
|
-
rubysl-openssl (~> 2.0)
|
|
102
|
-
rubysl-optparse (~> 2.0)
|
|
103
|
-
rubysl-ostruct (~> 2.0)
|
|
104
|
-
rubysl-pathname (~> 2.0)
|
|
105
|
-
rubysl-prettyprint (~> 2.0)
|
|
106
|
-
rubysl-prime (~> 2.0)
|
|
107
|
-
rubysl-profile (~> 2.0)
|
|
108
|
-
rubysl-profiler (~> 2.0)
|
|
109
|
-
rubysl-pstore (~> 2.0)
|
|
110
|
-
rubysl-pty (~> 2.0)
|
|
111
|
-
rubysl-rational (~> 2.0)
|
|
112
|
-
rubysl-resolv (~> 2.0)
|
|
113
|
-
rubysl-rexml (~> 2.0)
|
|
114
|
-
rubysl-rinda (~> 2.0)
|
|
115
|
-
rubysl-rss (~> 2.0)
|
|
116
|
-
rubysl-scanf (~> 2.0)
|
|
117
|
-
rubysl-securerandom (~> 2.0)
|
|
118
|
-
rubysl-set (~> 2.0)
|
|
119
|
-
rubysl-shellwords (~> 2.0)
|
|
120
|
-
rubysl-singleton (~> 2.0)
|
|
121
|
-
rubysl-socket (~> 2.0)
|
|
122
|
-
rubysl-stringio (~> 2.0)
|
|
123
|
-
rubysl-strscan (~> 2.0)
|
|
124
|
-
rubysl-sync (~> 2.0)
|
|
125
|
-
rubysl-syslog (~> 2.0)
|
|
126
|
-
rubysl-tempfile (~> 2.0)
|
|
127
|
-
rubysl-thread (~> 2.0)
|
|
128
|
-
rubysl-thwait (~> 2.0)
|
|
129
|
-
rubysl-time (~> 2.0)
|
|
130
|
-
rubysl-timeout (~> 2.0)
|
|
131
|
-
rubysl-tmpdir (~> 2.0)
|
|
132
|
-
rubysl-tsort (~> 2.0)
|
|
133
|
-
rubysl-un (~> 2.0)
|
|
134
|
-
rubysl-uri (~> 2.0)
|
|
135
|
-
rubysl-weakref (~> 2.0)
|
|
136
|
-
rubysl-webrick (~> 2.0)
|
|
137
|
-
rubysl-xmlrpc (~> 2.0)
|
|
138
|
-
rubysl-yaml (~> 2.0)
|
|
139
|
-
rubysl-zlib (~> 2.0)
|
|
140
|
-
rubysl-abbrev (2.0.4)
|
|
141
|
-
rubysl-base64 (2.0.0)
|
|
142
|
-
rubysl-benchmark (2.0.1)
|
|
143
|
-
rubysl-bigdecimal (2.0.2)
|
|
144
|
-
rubysl-cgi (2.0.1)
|
|
145
|
-
rubysl-cgi-session (2.0.1)
|
|
146
|
-
rubysl-cmath (2.0.0)
|
|
147
|
-
rubysl-complex (2.0.0)
|
|
148
|
-
rubysl-continuation (2.0.0)
|
|
149
|
-
rubysl-coverage (2.0.3)
|
|
150
|
-
rubysl-csv (2.0.2)
|
|
151
|
-
rubysl-english (~> 2.0)
|
|
152
|
-
rubysl-curses (2.0.1)
|
|
153
|
-
rubysl-date (2.0.8)
|
|
154
|
-
rubysl-delegate (2.0.1)
|
|
155
|
-
rubysl-digest (2.0.3)
|
|
156
|
-
rubysl-drb (2.0.1)
|
|
157
|
-
rubysl-e2mmap (2.0.0)
|
|
158
|
-
rubysl-english (2.0.0)
|
|
159
|
-
rubysl-enumerator (2.0.0)
|
|
160
|
-
rubysl-erb (2.0.2)
|
|
161
|
-
rubysl-etc (2.0.3)
|
|
162
|
-
ffi2-generators (~> 0.1)
|
|
163
|
-
rubysl-expect (2.0.0)
|
|
164
|
-
rubysl-fcntl (2.0.4)
|
|
165
|
-
ffi2-generators (~> 0.1)
|
|
166
|
-
rubysl-fiber (2.0.0)
|
|
167
|
-
rubysl-fileutils (2.0.3)
|
|
168
|
-
rubysl-find (2.0.1)
|
|
169
|
-
rubysl-forwardable (2.0.1)
|
|
170
|
-
rubysl-getoptlong (2.0.0)
|
|
171
|
-
rubysl-gserver (2.0.0)
|
|
172
|
-
rubysl-socket (~> 2.0)
|
|
173
|
-
rubysl-thread (~> 2.0)
|
|
174
|
-
rubysl-io-console (2.0.0)
|
|
175
|
-
rubysl-io-nonblock (2.0.0)
|
|
176
|
-
rubysl-io-wait (2.0.0)
|
|
177
|
-
rubysl-ipaddr (2.0.0)
|
|
178
|
-
rubysl-irb (2.1.0)
|
|
179
|
-
rb-readline (~> 0.5)
|
|
180
|
-
rubysl-e2mmap (~> 2.0)
|
|
181
|
-
rubysl-mathn (~> 2.0)
|
|
182
|
-
rubysl-thread (~> 2.0)
|
|
183
|
-
rubysl-logger (2.1.0)
|
|
184
|
-
rubysl-mathn (2.0.0)
|
|
185
|
-
rubysl-matrix (2.1.0)
|
|
186
|
-
rubysl-e2mmap (~> 2.0)
|
|
187
|
-
rubysl-mkmf (2.0.1)
|
|
188
|
-
rubysl-fileutils (~> 2.0)
|
|
189
|
-
rubysl-shellwords (~> 2.0)
|
|
190
|
-
rubysl-monitor (2.0.0)
|
|
191
|
-
rubysl-mutex_m (2.0.0)
|
|
192
|
-
rubysl-net-ftp (2.0.1)
|
|
193
|
-
rubysl-net-http (2.0.4)
|
|
194
|
-
rubysl-cgi (~> 2.0)
|
|
195
|
-
rubysl-erb (~> 2.0)
|
|
196
|
-
rubysl-singleton (~> 2.0)
|
|
197
|
-
rubysl-net-imap (2.0.1)
|
|
198
|
-
rubysl-net-pop (2.0.1)
|
|
199
|
-
rubysl-net-protocol (2.0.1)
|
|
200
|
-
rubysl-net-smtp (2.0.1)
|
|
201
|
-
rubysl-net-telnet (2.0.0)
|
|
202
|
-
rubysl-nkf (2.0.1)
|
|
203
|
-
rubysl-observer (2.0.0)
|
|
204
|
-
rubysl-open-uri (2.0.0)
|
|
205
|
-
rubysl-open3 (2.0.0)
|
|
206
|
-
rubysl-openssl (2.2.1)
|
|
207
|
-
rubysl-optparse (2.0.1)
|
|
208
|
-
rubysl-shellwords (~> 2.0)
|
|
209
|
-
rubysl-ostruct (2.0.4)
|
|
210
|
-
rubysl-pathname (2.1.0)
|
|
211
|
-
rubysl-prettyprint (2.0.3)
|
|
212
|
-
rubysl-prime (2.0.1)
|
|
213
|
-
rubysl-profile (2.0.0)
|
|
214
|
-
rubysl-profiler (2.0.1)
|
|
215
|
-
rubysl-pstore (2.0.0)
|
|
216
|
-
rubysl-pty (2.0.3)
|
|
217
|
-
rubysl-rational (2.0.1)
|
|
218
|
-
rubysl-resolv (2.1.0)
|
|
219
|
-
rubysl-rexml (2.0.4)
|
|
220
|
-
rubysl-rinda (2.0.1)
|
|
221
|
-
rubysl-rss (2.0.0)
|
|
222
|
-
rubysl-scanf (2.0.0)
|
|
223
|
-
rubysl-securerandom (2.0.0)
|
|
224
|
-
rubysl-set (2.0.1)
|
|
225
|
-
rubysl-shellwords (2.0.0)
|
|
226
|
-
rubysl-singleton (2.0.0)
|
|
227
|
-
rubysl-socket (2.0.1)
|
|
228
|
-
rubysl-stringio (2.0.0)
|
|
229
|
-
rubysl-strscan (2.0.0)
|
|
230
|
-
rubysl-sync (2.0.0)
|
|
231
|
-
rubysl-syslog (2.1.0)
|
|
232
|
-
ffi2-generators (~> 0.1)
|
|
233
|
-
rubysl-tempfile (2.0.1)
|
|
234
|
-
rubysl-thread (2.0.2)
|
|
235
|
-
rubysl-thwait (2.0.0)
|
|
236
|
-
rubysl-time (2.0.3)
|
|
237
|
-
rubysl-timeout (2.0.0)
|
|
238
|
-
rubysl-tmpdir (2.0.1)
|
|
239
|
-
rubysl-tsort (2.0.1)
|
|
240
|
-
rubysl-un (2.0.0)
|
|
241
|
-
rubysl-fileutils (~> 2.0)
|
|
242
|
-
rubysl-optparse (~> 2.0)
|
|
243
|
-
rubysl-uri (2.0.0)
|
|
244
|
-
rubysl-weakref (2.0.0)
|
|
245
|
-
rubysl-webrick (2.0.0)
|
|
246
|
-
rubysl-xmlrpc (2.0.0)
|
|
247
|
-
rubysl-yaml (2.1.0)
|
|
248
|
-
rubysl-zlib (2.0.1)
|
|
249
|
-
slop (3.6.0)
|
|
250
|
-
sqlite3 (1.3.10)
|
|
251
|
-
thread_safe (0.3.4)
|
|
252
|
-
tzinfo (1.2.2)
|
|
49
|
+
method_source (~> 0.9.0)
|
|
50
|
+
pry (0.11.3-java)
|
|
51
|
+
coderay (~> 1.1.0)
|
|
52
|
+
method_source (~> 0.9.0)
|
|
53
|
+
spoon (~> 0.0)
|
|
54
|
+
rack (2.0.5)
|
|
55
|
+
rake (12.3.0)
|
|
56
|
+
rdoc (6.0.1)
|
|
57
|
+
request_store (1.4.1)
|
|
58
|
+
rack (>= 1.4)
|
|
59
|
+
ruby-progressbar (1.9.0)
|
|
60
|
+
spoon (0.0.6)
|
|
61
|
+
ffi
|
|
62
|
+
sqlite3 (1.3.13)
|
|
63
|
+
thor (0.20.0)
|
|
64
|
+
thread_safe (0.3.6)
|
|
65
|
+
thread_safe (0.3.6-java)
|
|
66
|
+
tzinfo (1.2.5)
|
|
253
67
|
thread_safe (~> 0.1)
|
|
254
68
|
|
|
255
69
|
PLATFORMS
|
|
70
|
+
java
|
|
256
71
|
ruby
|
|
257
72
|
|
|
258
73
|
DEPENDENCIES
|
|
259
|
-
|
|
74
|
+
appraisal
|
|
75
|
+
database_cleaner
|
|
260
76
|
globalize!
|
|
77
|
+
m
|
|
261
78
|
minitest
|
|
262
79
|
minitest-reporters
|
|
263
80
|
pry
|
|
264
|
-
pry-nav
|
|
265
81
|
rake
|
|
266
82
|
rdoc
|
|
267
|
-
rubysl (~> 2.0)
|
|
268
83
|
sqlite3
|
|
84
|
+
|
|
85
|
+
BUNDLED WITH
|
|
86
|
+
1.17.1
|
data/{readme.md → README.md}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/globalize/globalize) [](https://codeclimate.com/github/globalize/globalize)
|
|
4
|
+
[](https://www.codetriage.com/globalize/globalize)
|
|
4
5
|
|
|
5
6
|
You can chat with us using Gitter:
|
|
6
7
|
|
|
@@ -9,6 +10,8 @@ You can chat with us using Gitter:
|
|
|
9
10
|
Globalize builds on the [I18n API in Ruby on Rails](http://guides.rubyonrails.org/i18n.html)
|
|
10
11
|
to add model translations to ActiveRecord models.
|
|
11
12
|
|
|
13
|
+
In other words, a way to translate actual user-generated content, for example; a single blog post with multiple translations.
|
|
14
|
+
|
|
12
15
|
## Requirements
|
|
13
16
|
|
|
14
17
|
* ActiveRecord >= 4.2.0 (see below for installation with ActiveRecord 3.x)
|
|
@@ -25,7 +28,16 @@ gem install globalize
|
|
|
25
28
|
When using bundler put this in your Gemfile:
|
|
26
29
|
|
|
27
30
|
```ruby
|
|
28
|
-
gem 'globalize', '~> 5.
|
|
31
|
+
gem 'globalize', '~> 5.1.0'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Please help us by letting us know what works, and what doesn't, when using pre-release code.
|
|
35
|
+
|
|
36
|
+
Put in your Gemfile
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
gem 'globalize', git: 'https://github.com/globalize/globalize'
|
|
40
|
+
gem 'activemodel-serializers-xml'
|
|
29
41
|
```
|
|
30
42
|
|
|
31
43
|
To use the version of globalize for ActiveRecord 4.0 or 4.1, specify:
|
|
@@ -80,19 +92,24 @@ and `drop_translation_table!` inside the `change` instance method.
|
|
|
80
92
|
|
|
81
93
|
### Creating translation tables
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
Also note that before you can create a translation table, you have to define the translated attributes via `translates` in your model as shown above.
|
|
84
96
|
|
|
85
97
|
```ruby
|
|
86
98
|
class CreatePosts < ActiveRecord::Migration
|
|
87
|
-
def
|
|
99
|
+
def change
|
|
88
100
|
create_table :posts do |t|
|
|
89
101
|
t.timestamps
|
|
90
102
|
end
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
|
|
104
|
+
reversible do |dir|
|
|
105
|
+
dir.up do
|
|
106
|
+
Post.create_translation_table! :title => :string, :text => :text
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
dir.down do
|
|
110
|
+
Post.drop_translation_table!
|
|
111
|
+
end
|
|
112
|
+
end
|
|
96
113
|
end
|
|
97
114
|
end
|
|
98
115
|
```
|
|
@@ -101,16 +118,21 @@ Also, you can pass options for specific columns. Here’s an example:
|
|
|
101
118
|
|
|
102
119
|
```ruby
|
|
103
120
|
class CreatePosts < ActiveRecord::Migration
|
|
104
|
-
def
|
|
121
|
+
def change
|
|
105
122
|
create_table :posts do |t|
|
|
106
123
|
t.timestamps
|
|
107
124
|
end
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
|
|
126
|
+
reversible do |dir|
|
|
127
|
+
dir.up do
|
|
128
|
+
Post.create_translation_table! :title => :string,
|
|
129
|
+
:text => {:type => :text, :null => false, :default => 'abc'}
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
dir.down do
|
|
133
|
+
Post.drop_translation_table!
|
|
134
|
+
end
|
|
135
|
+
end
|
|
114
136
|
end
|
|
115
137
|
end
|
|
116
138
|
```
|
|
@@ -130,6 +152,31 @@ model's attributes as they were before the translation was applied. Here's an
|
|
|
130
152
|
example (which assumes you already have a model called `Post` and its table
|
|
131
153
|
exists):
|
|
132
154
|
|
|
155
|
+
```ruby
|
|
156
|
+
class TranslatePosts < ActiveRecord::Migration
|
|
157
|
+
def change
|
|
158
|
+
reversible do |dir|
|
|
159
|
+
dir.up do
|
|
160
|
+
Post.create_translation_table!({
|
|
161
|
+
:title => :string,
|
|
162
|
+
:text => :text
|
|
163
|
+
}, {
|
|
164
|
+
:migrate_data => true
|
|
165
|
+
})
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
dir.down do
|
|
169
|
+
Post.drop_translation_table! :migrate_data => true
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
NOTE: Make sure you drop the translated columns from the parent table after all your data is safely migrated.
|
|
177
|
+
|
|
178
|
+
To automatically remove the translated columns from the parent table after the data migration, please use option `remove_source_columns`.
|
|
179
|
+
|
|
133
180
|
```ruby
|
|
134
181
|
class TranslatePosts < ActiveRecord::Migration
|
|
135
182
|
def self.up
|
|
@@ -137,7 +184,8 @@ class TranslatePosts < ActiveRecord::Migration
|
|
|
137
184
|
:title => :string,
|
|
138
185
|
:text => :text
|
|
139
186
|
}, {
|
|
140
|
-
:migrate_data => true
|
|
187
|
+
:migrate_data => true,
|
|
188
|
+
:remove_source_columns => true
|
|
141
189
|
})
|
|
142
190
|
end
|
|
143
191
|
|
|
@@ -147,7 +195,19 @@ class TranslatePosts < ActiveRecord::Migration
|
|
|
147
195
|
end
|
|
148
196
|
```
|
|
149
197
|
|
|
150
|
-
|
|
198
|
+
|
|
199
|
+
In order to use a specific locale for migrated data, you can use `I18n.with_locale`:
|
|
200
|
+
|
|
201
|
+
```ruby
|
|
202
|
+
I18n.with_locale(:bo) do
|
|
203
|
+
Post.create_translation_table!({
|
|
204
|
+
:title => :string,
|
|
205
|
+
:text => :text
|
|
206
|
+
}, {
|
|
207
|
+
:migrate_data => true
|
|
208
|
+
})
|
|
209
|
+
end
|
|
210
|
+
```
|
|
151
211
|
|
|
152
212
|
## Adding additional fields to the translation table
|
|
153
213
|
|
|
@@ -155,12 +215,16 @@ In order to add a new field to an existing translation table, you can use `add_t
|
|
|
155
215
|
|
|
156
216
|
```ruby
|
|
157
217
|
class AddAuthorToPost < ActiveRecord::Migration
|
|
158
|
-
def
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
218
|
+
def change
|
|
219
|
+
reversible do |dir|
|
|
220
|
+
dir.up do
|
|
221
|
+
Post.add_translation_fields! author: :text
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
dir.down do
|
|
225
|
+
remove_column :post_translations, :author
|
|
226
|
+
end
|
|
227
|
+
end
|
|
164
228
|
end
|
|
165
229
|
end
|
|
166
230
|
```
|
|
@@ -176,6 +240,24 @@ Because globalize uses the `:locale` key to specify the locale during
|
|
|
176
240
|
mass-assignment, you should avoid having a `locale` attribute on the parent
|
|
177
241
|
model.
|
|
178
242
|
|
|
243
|
+
If you like your translated model to update if a translation changes, use the `touch: true` option together with `translates`:
|
|
244
|
+
|
|
245
|
+
```ruby
|
|
246
|
+
translates :name, touch: true
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Known Issues
|
|
250
|
+
|
|
251
|
+
If you're getting the `ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: null value in column "column_name" violates not-null constraint` error, the only known way to deal with it as of now is to remove not-null constraint for the globalized columns:
|
|
252
|
+
|
|
253
|
+
```ruby
|
|
254
|
+
class RemoveNullConstraintsFromResourceTranslations < ActiveRecord::Migration
|
|
255
|
+
def change
|
|
256
|
+
change_column_null :resource_translations, :column_name, true
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
179
261
|
## Versioning with Globalize
|
|
180
262
|
|
|
181
263
|
See the [globalize-versioning](https://github.com/globalize/globalize-versioning) gem.
|
|
@@ -327,23 +409,29 @@ def cache_key
|
|
|
327
409
|
end
|
|
328
410
|
```
|
|
329
411
|
|
|
412
|
+
## Thread-safety
|
|
413
|
+
|
|
414
|
+
Globalize uses [request_store](https://github.com/steveklabnik/request_store) gem to clean up thread-global variable after every request.
|
|
415
|
+
RequestStore includes a Railtie that will configure everything properly for Rails 3+ apps.
|
|
416
|
+
|
|
417
|
+
If you're not using Rails, you may need to consult a RequestStore's [README](https://github.com/steveklabnik/request_store#no-rails-no-problem) to configure it.
|
|
418
|
+
|
|
419
|
+
## Tutorials and articles
|
|
420
|
+
* [Go Global with Rails and I18n](http://www.sitepoint.com/go-global-rails-i18n/) - introductory article about i18n in Rails (Ilya Bodrov)
|
|
421
|
+
|
|
330
422
|
## Official Globalize extensions
|
|
331
423
|
|
|
332
|
-
* [globalize-accessors](https://github.com/globalize/globalize-accessors) -
|
|
333
|
-
* [globalize-versioning](https://github.com/globalize/globalize-versioning) -
|
|
424
|
+
* [globalize-accessors](https://github.com/globalize/globalize-accessors) - generator of accessor methods for models. *(e.g. title_en, title_cz)*
|
|
425
|
+
* [globalize-versioning](https://github.com/globalize/globalize-versioning) - versioning support for using Globalize with [`paper_trail`](https://github.com/airblade/paper_trail). (compatible with Globalize 3.x and 4.x)
|
|
334
426
|
|
|
335
|
-
## Alternative
|
|
427
|
+
## Alternative solutions
|
|
336
428
|
|
|
337
|
-
* [
|
|
338
|
-
* [
|
|
339
|
-
* [
|
|
340
|
-
* [
|
|
341
|
-
* [
|
|
342
|
-
* [hstore_translate](http://github.com/robworley/hstore_translate) - Rails I18n library for ActiveRecord model/data translation using PostgreSQL's hstore datatype (Rob Worley)
|
|
429
|
+
* [Traco](https://github.com/barsoom/traco) - use multiple columns in the same model (Barsoom)
|
|
430
|
+
* [Mobility](https://github.com/shioyama/mobility) - pluggable translation framework supporting many strategies, including translatable columns, translation tables and hstore/jsonb (Chris Salzberg)
|
|
431
|
+
* [hstore_translate](https://github.com/cfabianski/hstore_translate) - use PostgreSQL's hstore datatype to store translations, instead of separate translation tables (Cédric Fabianski)
|
|
432
|
+
* [json_translate](https://github.com/cfabianski/json_translate) - use PostgreSQL's json/jsonb datatype to store translations, instead of separate translation tables (Cédric Fabianski)
|
|
433
|
+
* [Trasto](https://github.com/yabawock/trasto) - store translations directly in the model in a Postgres Hstore column
|
|
343
434
|
|
|
344
435
|
## Related solutions
|
|
345
436
|
|
|
346
|
-
* [
|
|
347
|
-
* [i18n_multi_locales_validations](http://github.com/ZenCocoon/i18n_multi_locales_validations) - multi-locales attributes validations to validates attributes from globalize2 translations models (Sébastien Grosjean)
|
|
348
|
-
* [migrate_from_globalize1](http://gist.github.com/120867) - migrate model translations from Globalize1 to globalize2 (Tomasz Stachewicz)
|
|
349
|
-
* [batch_translations](http://github.com/rilla/batch_translations) - allow saving multiple globalize2 translations in the same request (Jose Alvarez Rilla)
|
|
437
|
+
* [friendly_id-globalize](https://github.com/norman/friendly_id-globalize) - lets you use Globalize to translate slugs (Norman Clarke)
|