Module: Spree::LocaleHelper

Defined in:
app/helpers/spree/locale_helper.rb

Instance Method Summary collapse

Instance Method Details

#admin_locales_optionsObject

Locales the admin UI is translated into, as [name, code] pairs for a select. Self-contained (reads Spree.available_locales directly) so it works outside the storefront/admin controller stack — e.g. the pre-auth login screen, which has no current store.



11
12
13
# File 'app/helpers/spree/locale_helper.rb', line 11

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

#all_locales_optionsObject



3
4
5
# File 'app/helpers/spree/locale_helper.rb', line 3

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

#available_locales_optionsObject



15
16
17
# File 'app/helpers/spree/locale_helper.rb', line 15

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

#locale_presentation(locale) ⇒ Object



34
35
36
# File 'app/helpers/spree/locale_helper.rb', line 34

def locale_presentation(locale)
  [Spree::Locale.new(code: locale).label, locale.to_s]
end

#should_render_locale_dropdown?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'app/helpers/spree/locale_helper.rb', line 38

def should_render_locale_dropdown?
  return false if current_store.nil?

  current_store.supported_locales_list.size > 1
end

#supported_locales_optionsObject



28
29
30
31
32
# File 'app/helpers/spree/locale_helper.rb', line 28

def supported_locales_options
  return if current_store.nil?

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

#translation_locales_optionsObject

Locales a merchant may translate content into, as [name, code] pairs for a select. Backed by Spree::Locales::ALL (the canonical translation locale set) rather than the installed UI-translation bundles, so a market/store can adopt any supported locale instead of only ones already in use.



24
25
26
# File 'app/helpers/spree/locale_helper.rb', line 24

def translation_locales_options
  Spree::Locales::ALL.map { |locale| locale_presentation(locale) }
end