14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/models/concerns/hancock/model_localizeable.rb', line 14
def convert2localize(save_it = true)
arr = {}
self.localized_fields.keys.each do |f|
if self[f].is_a?(Hash) and f !~ /_translations$/
self[f + '_translations'] = self.remove_attribute(f)
else
arr[f] = self.remove_attribute(f)
self[f] = {}
end
end
self.save if save_it
I18n.available_locales.each do |l|
I18n.with_locale(l) do
arr.each_pair do |f, v|
self.send(f + "=", v)
end
end
end
self.save if save_it
end
|