Module: Hancock::ModelLocalizeable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/hancock/model_localizeable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#convert2localize(save_it = true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/hancock/model_localizeable.rb', line 12 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 |