python flask detect browser language_flask

 


No problem. We won't show you that ad again. Why didn't you like it?

  • Uninteresting
  • Misleading
  • Offensive
  • Repetitive
  • Other

​Oops! I didn't mean to do this.​






2 Answers                                 2



​            active​​         ​​            oldest​​         ​​            votes​


            


 


No problem. We won't show you that ad again. Why didn't you like it?

  • Uninteresting
  • Misleading
  • Offensive
  • Repetitive
  • Other

​Oops! I didn't mean to do this.​



         up vote0down vote




Check out Werkzeug's ​​LanguageAccept data structure​​, or just try something like this to get a best match:

supported_languages = ["en", "nl", "it"]
lang = request.accept_languages.best_match(supported_languages)


If you need more than that, then check out ​​Flask-Babel​​.



What Doesn't Kill Me Makes Me Stronger