globalize3 0.2.0.beta8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -79,7 +79,7 @@ module Globalize
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def set_metadata(object, metadata)
|
82
|
-
object.translation_metadata.merge!(
|
82
|
+
object.translation_metadata.merge!(metadata) if object.respond_to?(:translation_metadata)
|
83
83
|
object
|
84
84
|
end
|
85
85
|
|
@@ -98,7 +98,9 @@ module Globalize
|
|
98
98
|
scope = scope.send(:"scoped_by_#{unt}", arguments[index])
|
99
99
|
end
|
100
100
|
|
101
|
-
return scope.send(match.finder)
|
101
|
+
return scope.send(match.finder).tap do |found|
|
102
|
+
found.is_a?(Array) ? found.map { |f| f.translations.reload } : found.translations.reload unless found.nil?
|
103
|
+
end if match.is_a?(::ActiveRecord::DynamicFinderMatch)
|
102
104
|
return scope
|
103
105
|
end
|
104
106
|
|
@@ -32,6 +32,7 @@ module Globalize
|
|
32
32
|
move_data_to_translation_table if options[:migrate_data]
|
33
33
|
remove_source_columns if options[:remove_source_columns]
|
34
34
|
create_translations_index
|
35
|
+
clear_schema_cache!
|
35
36
|
end
|
36
37
|
|
37
38
|
def remove_source_columns
|
@@ -44,6 +45,7 @@ module Globalize
|
|
44
45
|
move_data_to_model_table if options[:migrate_data]
|
45
46
|
drop_translations_index
|
46
47
|
drop_translation_table
|
48
|
+
clear_schema_cache!
|
47
49
|
end
|
48
50
|
|
49
51
|
def complete_translated_fields
|
@@ -83,23 +85,13 @@ module Globalize
|
|
83
85
|
end
|
84
86
|
|
85
87
|
def move_data_to_translation_table
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# translation.save!
|
94
|
-
# end
|
95
|
-
|
96
|
-
# Find all of the existing untranslated attributes for this model.
|
97
|
-
all_model_fields = @model.all
|
98
|
-
model_attributes = all_model_fields.map(&:untranslated_attributes)
|
99
|
-
all_model_fields.each do |model_record|
|
100
|
-
# Assign the attributes back to the model which will enable globalize3 to translate them.
|
101
|
-
model_record.attributes = model_attributes.detect{|a| a['id'] == model_record.id}
|
102
|
-
model_record.save!
|
88
|
+
model.find_each do |record|
|
89
|
+
untranslated_attributes = record.untranslated_attributes
|
90
|
+
translation = record.translations.build(:locale => I18n.default_locale)
|
91
|
+
translated_attribute_names.each do |attribute|
|
92
|
+
translation[attribute] = untranslated_attributes[attribute.to_s]
|
93
|
+
end
|
94
|
+
translation.save!
|
103
95
|
end
|
104
96
|
end
|
105
97
|
|
@@ -144,6 +136,9 @@ module Globalize
|
|
144
136
|
index_name.size < 50 ? index_name : "index_#{Digest::SHA1.hexdigest(index_name)}"
|
145
137
|
end
|
146
138
|
|
139
|
+
def clear_schema_cache!
|
140
|
+
connection.schema_cache.clear! if connection.respond_to? :schema_cache
|
141
|
+
end
|
147
142
|
|
148
143
|
private
|
149
144
|
|
@@ -158,4 +153,4 @@ module Globalize
|
|
158
153
|
end
|
159
154
|
end
|
160
155
|
end
|
161
|
-
end
|
156
|
+
end
|
data/lib/globalize3/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalize3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 8
|
12
|
-
version: 0.2.0.beta8
|
10
|
+
version: 0.2.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Sven Fuchs
|
@@ -22,7 +20,7 @@ autorequire:
|
|
22
20
|
bindir: bin
|
23
21
|
cert_chain: []
|
24
22
|
|
25
|
-
date: 2012-02-
|
23
|
+
date: 2012-02-29 00:00:00 Z
|
26
24
|
dependencies:
|
27
25
|
- !ruby/object:Gem::Dependency
|
28
26
|
name: activerecord
|
@@ -194,20 +192,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
193
|
none: false
|
196
194
|
requirements:
|
197
|
-
- - "
|
195
|
+
- - ">="
|
198
196
|
- !ruby/object:Gem::Version
|
199
|
-
hash:
|
197
|
+
hash: 3
|
200
198
|
segments:
|
201
|
-
-
|
202
|
-
|
203
|
-
- 1
|
204
|
-
version: 1.3.1
|
199
|
+
- 0
|
200
|
+
version: "0"
|
205
201
|
requirements: []
|
206
202
|
|
207
203
|
rubyforge_project: "[none]"
|
208
|
-
rubygems_version: 1.8.
|
204
|
+
rubygems_version: 1.8.17
|
209
205
|
signing_key:
|
210
206
|
specification_version: 3
|
211
207
|
summary: "Rails I18n: de-facto standard library for ActiveRecord 3 model/data translation"
|
212
208
|
test_files: []
|
213
209
|
|
210
|
+
has_rdoc:
|