Module: Spree::LocaleHelper
- Defined in:
- app/helpers/spree/locale_helper.rb
Instance Method Summary collapse
-
#admin_locales_options ⇒ Object
Locales the admin UI is translated into, as [name, code] pairs for a select.
- #all_locales_options ⇒ Object
- #available_locales_options ⇒ Object
- #locale_presentation(locale) ⇒ Object
- #should_render_locale_dropdown? ⇒ Boolean
- #supported_locales_options ⇒ Object
-
#translation_locales_options ⇒ Object
Locales a merchant may translate content into, as [name, code] pairs for a select.
Instance Method Details
#admin_locales_options ⇒ Object
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 Spree.available_locales.map { |locale| locale_presentation(locale) } end |
#all_locales_options ⇒ Object
3 4 5 |
# File 'app/helpers/spree/locale_helper.rb', line 3 def supported_locales_for_all_stores.map { |locale| locale_presentation(locale) } end |
#available_locales_options ⇒ Object
15 16 17 |
# File 'app/helpers/spree/locale_helper.rb', line 15 def 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
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_options ⇒ Object
28 29 30 31 32 |
# File 'app/helpers/spree/locale_helper.rb', line 28 def return if current_store.nil? current_store.supported_locales_list.map { |locale| locale_presentation(locale) } end |
#translation_locales_options ⇒ Object
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 Spree::Locales::ALL.map { |locale| locale_presentation(locale) } end |