Sha256: 37ae472a67ee1eb2c7903840726fe9b7259dba9d30e66b661cf67597181cd4bd

Contents?: true

Size: 874 Bytes

Versions: 9

Compression:

Stored size: 874 Bytes

Contents

module Spree
  module LocaleHelper
    def all_locales_options
      supported_locales_for_all_stores.map { |locale| locale_presentation(locale) }
    end

    def available_locales_options
      available_locales.map { |locale| locale_presentation(locale) }
    end

    def supported_locales_options
      return if current_store.nil?

      current_store.supported_locales_list.map { |locale| locale_presentation(locale) }
    end

    def locale_presentation(locale)
      if I18n.exists?('spree.i18n.this_file_language', locale: locale)
        [Spree.t('i18n.this_file_language', locale: locale), locale.to_s]
      else
        locale.to_s == 'en' ? ['English (US)', 'en'] : [locale, locale.to_s]
      end
    end

    def should_render_locale_dropdown?
      return false if current_store.nil?

      current_store.supported_locales_list.size > 1
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_core-4.2.7 app/helpers/spree/locale_helper.rb
spree_core-4.2.6 app/helpers/spree/locale_helper.rb
spree_core-4.2.5 app/helpers/spree/locale_helper.rb
spree_core-4.2.4 app/helpers/spree/locale_helper.rb
spree_core-4.2.3.1 app/helpers/spree/locale_helper.rb
spree_core-4.2.3 app/helpers/spree/locale_helper.rb
spree_core-4.2.2 app/helpers/spree/locale_helper.rb
spree_core-4.2.1 app/helpers/spree/locale_helper.rb
spree_core-4.2.0 app/helpers/spree/locale_helper.rb