Sha256: fb89fb7343fa7dd22e270af3c3c42a0e48357ea06321a4d48041f866a67c7f26

Contents?: true

Size: 601 Bytes

Versions: 8

Compression:

Stored size: 601 Bytes

Contents

module Spina
  module Pages
    class TranslationsComponent < ApplicationComponent
      def initialize(page, label: nil)
        @page = page
        @label = label
      end

      def render?
        spina_locales.many?
      end

      def missing_locales
        spina_locales - existing_locales
      end

      def existing_locales
        @existing_locales ||= @page.translations.pluck(:locale).map(&:to_sym).sort_by do |locale|
          spina_locales.index(locale)
        end
      end

      private

      def spina_locales
        Spina.locales.map(&:to_sym)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spina-2.18.0 app/components/spina/pages/translations_component.rb
spina-2.17.0 app/components/spina/pages/translations_component.rb
spina-2.16.0 app/components/spina/pages/translations_component.rb
spina-2.15.1 app/components/spina/pages/translations_component.rb
spina-2.15.0 app/components/spina/pages/translations_component.rb
spina-2.14.0 app/components/spina/pages/translations_component.rb
spina-2.13.1 app/components/spina/pages/translations_component.rb
spina-2.13.0 app/components/spina/pages/translations_component.rb