Module: LocaleSetter::HTTP::AcceptLanguageParser
- Defined in:
- lib/locale_setter/http.rb
Constant Summary collapse
- LOCALE_SEPARATOR =
','
- WEIGHT_SEPARATOR =
';'
Class Method Summary collapse
Class Method Details
.parse(accept_language) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/locale_setter/http.rb', line 11 def self.parse(accept_language) locale_fragments = accept_language.split(LOCALE_SEPARATOR) weighted_fragments = locale_fragments.map{|f| f.split(WEIGHT_SEPARATOR)} sorted_fragments = weighted_fragments.sort_by{|f| -f.last.to_f } sorted_fragments.map{|locale, weight| locale} end |