Detecting language preference with Javascript. One way, using using Javascript only:
var language = window.navigator.userLanguage || window.navigator.language;
The better way is to use Ajax to grab the HTTP Accept-Language
header with a server side script. The Stackoverflow thread has implementations for Python ja Node.js.