Class: Spina::Pages::TranslationsComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/spina/pages/translations_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(page, label: nil) ⇒ TranslationsComponent

Returns a new instance of TranslationsComponent.



4
5
6
7
# File 'app/components/spina/pages/translations_component.rb', line 4

def initialize(page, label: nil)
  @page = page
  @label = label
end

Instance Method Details

#existing_localesObject



17
18
19
20
21
# File 'app/components/spina/pages/translations_component.rb', line 17

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

#missing_localesObject



13
14
15
# File 'app/components/spina/pages/translations_component.rb', line 13

def missing_locales
  spina_locales - existing_locales
end

#render?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/components/spina/pages/translations_component.rb', line 9

def render?
  spina_locales.many?
end