By default I set the lang attribute on html element server side, you could do that and read it using JavaScript.
Hope this helps.
Frederik