Sha256: 77b75c3ea510a0304b1e8c4033d9af309f8ce811c1bacd115c7cdcbcbb096665

Contents?: true

Size: 778 Bytes

Versions: 60

Compression:

Stored size: 778 Bytes

Contents

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

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

      result = super(*attr_names)

      unless 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|
        next if Rails.application.config.lalala.i18n.excluded_locales.try(:include?, 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

60 entries across 60 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.425 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.420 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.419 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.418 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.417 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.416 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.415 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.414 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.413 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.412 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.411 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.410 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.409 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.407 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.408 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.398 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.397 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.396 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.0.0.dev.395 lib/lalala/ext_active_record/i18n_translations_writer.rb
lalala-4.1.0.dev.394 lib/lalala/ext_active_record/i18n_translations_writer.rb