Detect language of a web page

Hi,

I want to determine language of a webpage. I researched and found a couple of things:

There are 3 different ways that is used to mention the language:

  1. the HTML tag
<html lang="en">

</html>

  1. In XHTML, the language is declared inside the <html> tag as follows:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...
</html>

  1. The meta tag
<meta http-equiv="Content-Language" content="ru"/>

Is there any other way ? Can any use use preg_match and give me a code/function that give me the language code ? (en, ru, gr, fr,etc etc) ?

Best Regards
ZH