Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. def set_locale
  2. logger.debug "* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}"
  3. I18n.locale = extract_locale_from_accept_language_header
  4. logger.debug "* Locale set to '#{I18n.locale}'"
  5. end
  6.  
  7. private
  8.  
  9. def extract_locale_from_accept_language_header
  10. request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
  11. end
Add Comment
Please, Sign In to add comment