0

I have a Data Table which I need to sort according to the user's input language. for example : if the user wrote in English, I will first display all the fields that their name written in English, and only afterwords all the other languages.

I cant write "hard coded" string that will match the inputs to see where it fits, since I don't know the customer language

Is there a way to detect the OS current Language? I rather not use a third party for it...

EDIT : the Browser language doesn't seems to help since its stays en-US even If I change with ALT + SHIFT and write in a another language

Thank you very much!

tal faran
  • 117
  • 2
  • 10

2 Answers2

1

You need to use the Navigator object.

const lang = navigator.language

It's worth noting this is the language of the browser, more often than not this will be the same as the OS. the browser support is limited, see below for more info.

Visit for more info

C Douglas
  • 11
  • 2
0

Have a look at this Question: How to get the browser language using JavaScript

With this code you can get the Browser language.

Lukas Neumann
  • 656
  • 5
  • 18