To build a multilingual website, it is important to know language preferences of users. There are two ways for frontend programmers to detect browser language preference:
- Via NavigatorLanguage API: This API contains properties (language and languages) to indicate the preferred language of the browser user. This post will mainly focus on how to use this API.
- Via Accept-Language header in HTTP request: There is no way to directly access this header in your code. You can, however, run a server which returns the headers to client browser via JSONP. See  for more details.