Sha256: 8d51a3ccff622c45ccd3a7522e62c1b2fb9b7eb4db523471a114fa59eb0e9fe1

Contents?: true

Size: 799 Bytes

Versions: 24

Compression:

Stored size: 799 Bytes

Contents

module ActiveadminSelleoCms
  module ContentTranslation

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
    end

    def initialize_missing_translations
      Locale.available_locale_codes.each do |locale_code|
        translations.build(locale: locale_code) unless translations.detect{|t| t.locale == locale_code}
      end
    end

    def create_missing_translations
      Locale.available_locale_codes.each do |locale_code|
        translations.create(locale: locale_code) unless translations.detect{|t| t.locale == locale_code}
      end
    end

    def translated_attribute(attr, locale)
      _locale = I18n.locale
      I18n.locale = locale
      translation = send(attr.to_sym)
      I18n.locale = _locale
      translation
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
activeadmin-selleo-cms-0.0.61 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.60 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.59 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.58 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.54 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.52 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.51 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.49 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.48 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.47 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.46 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.45 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.44 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.43 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.42 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.41 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.40 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.39 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.38 app/modules/activeadmin_selleo_cms/content_translation.rb
activeadmin-selleo-cms-0.0.37 app/modules/activeadmin_selleo_cms/content_translation.rb