Files
nairobi/app/components/layout/locale_switcher_component.rb
2021-07-05 22:27:39 +02:00

20 lines
417 B
Ruby

class Layout::LocaleSwitcherComponent < ApplicationComponent
delegate :name_for_locale, :current_path_with_query_params, to: :helpers
def render?
locales.size > 1
end
private
def locales
I18n.available_locales
end
def language_options
locales.map do |locale|
[name_for_locale(locale), current_path_with_query_params(locale: locale), lang: locale]
end
end
end