I am sure this is very easy and I just am a little stupid asking this question. But do anybody know where I can find a script that does this for me:

1: Detect the browser or OS language.
2: Use this language for the website.

The script has to be used for mobile devices, but I don't think it complicates anything.