In my Angular2 application, I am looking to identify the browser language and use that information to send a request to the backend REST API with localization settings and variable IDs that require translation. Once the request is processed, I will receive a response containing the translated variables.
The workflow of the app involves detecting the browser language, for example en-US
, and then sending a request to the backend for the English (US) language localization of variables with IDs 1, 2, 3, 4, and 5. The response would include translations such as
{{id:1, var:pay}, {id:1, var:title}}
.
My question is, how can I implement browser language detection in Angular2 (using TypeScript)?