Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect user's language [duplicate]

I'm going to detect user's keyboard language by javascript. I got a input (type of text) which should be filled with Persian characters. So, I need to alarm users change their keyboard language if their language is not Persian.

What I have found is this:

window.navigator.language;

which detects browser's language which is always En-us.

How could I solve that?

like image 476
Super Hornet Avatar asked Sep 01 '13 10:09

Super Hornet


1 Answers

You can try like this:-

var language = window.navigator.userLanguage || window.navigator.language;
alert(language);

navigator.userLanguage works for IE

window.navigator.language works for firefox/opera/safari

Also check out this Thread

like image 65
Rahul Tripathi Avatar answered Sep 21 '22 10:09

Rahul Tripathi