module RailsLanguageSelect::TagHelper
Public Instance Methods
Private Instance Methods
all_language_codes()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 60 def all_language_codes codes = ::RailsLanguageSelect::DATA_SOURCE[data_source].call if only_language_codes.present? codes & only_language_codes.map{|code| code.to_s.upcase} elsif except_language_codes.present? codes - except_language_codes.map{|code| code.to_s.upcase} else codes end end
data_source()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 52 def data_source @options[:data_source] || :default end
except_language_codes()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 44 def except_language_codes @options[:except] end
format()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 48 def format @options[:format] || :default end
html_safe_newline()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 99 def html_safe_newline "\n".html_safe end
language_options()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 56 def language_options language_options_for(all_language_codes, true) end
language_options_for(language_codes, sorted=true)
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 72 def language_options_for(language_codes, sorted=true) I18n.with_locale(locale) do language_list = language_codes.map do |code_or_name| language, code = ::RailsLanguageSelect::DATA_SOURCE[data_source].call(code_or_name) unless language.present? msg = "Could not find Language with string '#{code_or_name}'" raise LanguageNotFoundError.new(msg) end formatted_language = ::RailsLanguageSelect::FORMATS[format].call(language, code) if formatted_language.is_a?(Array) formatted_language else [formatted_language, code] end end if sorted language_list.sort_alphabetical else language_list end end end
locale()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 28 def locale @options[:locale] end
only_language_codes()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 40 def only_language_codes @options[:only] end
priority_languages()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 32 def priority_languages @options[:priority_languages] end
priority_languages_divider()
click to toggle source
# File lib/rails_language_select/tag_helper.rb, line 36 def priority_languages_divider @options[:priority_languages_divider] || "-"*15 end