TIL how to get the active language of a browser


Today I learned how to get the selected language of a browser.

It's super simple!

const userLang = navigator.language || navigator.userLanguage;

An interesting discovery

Eventhough I'm using a chromium-based browser, the user-agent and some other fields of the navigator object imply that I'm running Mozilla Netscape 5.0. This is a relic of the past, where the user agent heavily influenced the look and feel of a served website. Nowadays, all rendering engines work more or less equally, but back then, browsers tried to be as good as the market leader, so they disquised themselves as Netscape. This podcast episode goes into more detail about how this developed (jump to minute 3 to listen to this topic):

This is post 024 of #100DaysToOffload.


Continue Reading