This is a n-gram based language detector, written in ruby.
For technical details about language detection, I recommend this paper: www.sfs.uni-tuebingen.de/iscl/Theses/kranig.pdf
sudo gem sources -a gems.github.com (you only have to do this once) sudo gem install feedbackmine-language_detector
require 'language_detector' d = LanguageDetector.new p d.detect('this text is in English')
Kevin Burton (feedblog.org/2005/08/19/ngram-language-categorization-source/ ). I used all the training data in his ngramcat project.