I first check the navigator.languages array for its first element.
Then I get either navigator.userLanguage or navigator.language.
If this fails we get navigator.browserLanguage.
const getNavigatorLanguage = () =>
(navigator.languages && navigator.languages.length) ?
navigator.languages[0] :
navigator.userLanguage ||
navigator.language ||
navigator.browserLanguage
I can get the result depending on the location in the format: en-US, fr-FR, pl-PL, es-ES. Is it possible to get the result in the format: en, fr, pl, es?
Without US,FR, PL,ES