Module: Spree::LocaleHelper
- Defined in:
- app/helpers/spree/locale_helper.rb
Instance Method Summary collapse
- #all_locales_options ⇒ Object
- #available_locales_options ⇒ Object
- #locale_full_name(locale) ⇒ Object
- #locale_presentation(locale) ⇒ Object
- #should_render_locale_dropdown? ⇒ Boolean
- #supported_locales_options ⇒ Object
Instance Method Details
#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
7 8 9 |
# File 'app/helpers/spree/locale_helper.rb', line 7 def available_locales.map { |locale| locale_presentation(locale) } end |
#locale_full_name(locale) ⇒ Object
29 30 31 |
# File 'app/helpers/spree/locale_helper.rb', line 29 def locale_full_name(locale) Spree.t('i18n.this_file_language', locale: locale) end |
#locale_presentation(locale) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/spree/locale_helper.rb', line 17 def locale_presentation(locale) if I18n.exists?('spree.i18n.this_file_language', locale: locale, fallback: false) [locale_full_name(locale), locale.to_s] elsif defined?(SpreeI18n::Locale) && (language_name = SpreeI18n::Locale.local_language_name(locale)) ["#{language_name} (#{locale})", locale.to_s] elsif locale.to_s == 'en' ['English (US)', 'en'] else [locale, locale.to_s] end end |
#should_render_locale_dropdown? ⇒ Boolean
33 34 35 36 37 |
# File 'app/helpers/spree/locale_helper.rb', line 33 def should_render_locale_dropdown? return false if current_store.nil? current_store.supported_locales_list.size > 1 end |
#supported_locales_options ⇒ Object
11 12 13 14 15 |
# File 'app/helpers/spree/locale_helper.rb', line 11 def return if current_store.nil? current_store.supported_locales_list.map { |locale| locale_presentation(locale) } end |