Module: Workarea::Storefront::LocalesHelper

Defined in:
app/helpers/workarea/storefront/locales_helper.rb

Instance Method Summary collapse

Instance Method Details

#alternate_locale_urlsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/workarea/storefront/locales_helper.rb', line 12

def alternate_locale_urls
  I18n.configured_locales.reduce({}) do |memo, locale|
    next memo if locale == I18n.locale || locale.blank?

    memo[locale] = if locale == I18n.default_locale
                     url_for(locale: nil)
                   else
                     url_for(locale: locale)
                   end

    memo
  end
end

#alternate_locales_tagsObject



4
5
6
7
8
9
10
# File 'app/helpers/workarea/storefront/locales_helper.rb', line 4

def alternate_locales_tags
  return if I18n.configured_locales.one?

  alternate_locale_urls.reduce('') do |memo, (locale, url)|
    memo << tag(:link, href: url, rel: 'alternate', hreflang: locale)
  end.html_safe
end