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.161 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.160 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.157 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.156 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.155 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.154 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.153 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.152 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.149 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.146 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.144 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.141 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.136 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.135 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.134 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.133 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.132 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.131 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.129 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.128 lib/lalala/ext_active_record/i18n_translations_writer.rb