Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
No way, flask is a backend. His area of responsibility is only you server. The server is your machine. Python does not have access to the client browser without js.
You can only read headers and cookies.
The browser sends Accept-Language headers , you can also rely on geolocation.
But this should only be used as a way to determine the default language. Provide a way for the user to explicitly change the language.
Django defines it this way, everything for Flask already has something similar, well, or repeat it yourself
First, it looks for the language prefix in the requested URL. This is only performed when you are using the i18n_patterns function in your root URLconf. See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns.
Failing that, it looks for a cookie.
The name of the cookie used is set by the LANGUAGE_COOKIE_NAME setting. (The default name is django_language.)
Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
Failing that, it uses the global LANGUAGE_CODE settin
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question