language-detection

Detect web user's language, e.g. in JavaScript?


I'm thinking of doing multiple language versions of my website (e.g. English and German). I'd like to offer a reasonable default based on the user's language.

What's the easiest and least obstrusive way to do that?

EDIT: The ideal solution would be not to use any server-side technology, but to encode everything in the html-files. Currently, I have a starting page that auto-forwards to the main page. If possible, I'd like to make that a bit "smarter" so that it forwards to either the German or the English version.


Solution

  • I believe properties are either navigator.language or navigator.userLanguage.