Module: Spotlight::LanguagesHelper
- Included in:
 - ApplicationHelper
 
- Defined in:
 - app/helpers/spotlight/languages_helper.rb
 
Overview
Helpers for the Language form and UI elements
Instance Method Summary collapse
- #add_exhibit_language_dropdown_options ⇒ Object
 - 
  
    
      #default_language?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Can determine whether the current page is using the application’s default locale.
 - #locale_selecter_dropown_options ⇒ Object
 
Instance Method Details
#add_exhibit_language_dropdown_options ⇒ Object
      7 8 9 10 11 12 13 14 15 16 17  | 
    
      # File 'app/helpers/spotlight/languages_helper.rb', line 7 def non_default_or_current_exhibit_languages = I18n.available_locales.reject do |locale| locale == I18n.default_locale || current_exhibit.available_locales.include?(locale.to_s) end non_default_or_current_exhibit_languages_with_labels = non_default_or_current_exhibit_languages.map do |locale| [t("locales.#{locale}"), locale] end non_default_or_current_exhibit_languages_with_labels.sort_by { |label, _locale| label } end  | 
  
#default_language? ⇒ Boolean
Can determine whether the current page is using the application’s default locale
      30 31 32 33 34  | 
    
      # File 'app/helpers/spotlight/languages_helper.rb', line 30 def default_language? return true unless params[:locale] params[:locale].to_s == I18n.default_locale.to_s end  | 
  
#locale_selecter_dropown_options ⇒ Object
      19 20 21 22 23 24  | 
    
      # File 'app/helpers/spotlight/languages_helper.rb', line 19 def languages = current_exhibit.languages.accessible_by(current_ability).to_a << Spotlight::Language.default_instance # String#casecmp returns 0 when the two strings compared are identical (ignoring case) languages.reject { |language| language.locale.to_s.casecmp(I18n.locale.to_s).zero? }.sort_by(&:to_native) end  |