How can I get the browser language in node.js (express.js)?

User requests some page and I want to know (on server side) what is the language in his/her browser. So I could render template with the right messages.

On client side it’s easy:

var language = window.navigator.userLanguage || window.navigator.language


You can use req.headers[“accept-language”] to get the language/locale the user has set in his browser.

For easier support, you may want to look into a locale module.

Source : Link , Question Author : Oleg Dats , Answer Author : Joachim Isaksson

Leave a Comment