Python Flask Detect Browser language
Up vote-2down Votefavorite |
I need to get the browser language with Python flask. I have the tried to use: request.headers.get(‘languages‘)
This however returns None . I tried whoer.net and it returned for it-IT my browser language. How can I detect the browser language with Python flask? Python flask
Share|improve this question |
edited May 25 ' At 14:50 IanAuld 4,621 119 35 |
Asked at 16:46 pythonfun 5 |
|
|
|
have you tried something like print (request.headers) to see what's in there? – IanAuld may "at 14:50 |
Add a Comment | |
2 Answers2Active oldest votes
Up vote0down vote |
You should checkHTTP_ACCEPT_LANGUAGE
Share|improve This answer |
answered at 16:53 Anthony Kong 9,285 c4> |
|
|
|
this does not provide a answer to the question. To critique or request clarification from an author, leave a comment below their post. – ken Y-N may "at 1:29 |
Add a Comment | |
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 this, then check out Flask-babel. |
Python Flask Detect Browser language