Sha256: f76fbe3498f1ae6e0191220eee605bb0653e4837067230538e7cb9bf03a2ec6e

Contents?: true

Size: 681 Bytes

Versions: 76

Compression:

Stored size: 681 Bytes

Contents

module Lalala::ExtActiveRecord::I18nTranslationsWriter
  extend ActiveSupport::Concern

  module ClassMethods
    def translates(*attr_names)
      init = translates?

      result = super(*attr_names)

      if init
        include Writer
        attr_accessible :translations_writer
      end

      result
    end
  end

  module Writer
    def translations_writer=(attributes)
      _locale = I18n.locale

      I18n.available_locales.each do |locale|
        I18n.locale = locale
        attrs = attributes[locale.to_s]
        if attrs
          self.assign_attributes(attrs)
        end
      end

      attributes
    ensure
      I18n.locale = _locale
    end
  end

end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.192 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.191 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.190 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.189 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.188 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.187 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.186 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.185 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.184 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.183 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.181 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.180 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.179 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.178 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.177 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.176 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.170 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.168 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.165 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.162 lib/lalala/ext_active_record/i18n_translations_writer.rb