The simplest way to use JLangDetect is to use the UberLanguageDetector singleton, available in the jlangdetect-extra module :
import me.champeau.ld.UberLanguageDetector;
UberLanguageDetector detector = UberLanguageDetector.getInstance();
// ..
String language = detector.detectLang("ceci est un petit texte en français");
Alternatively, if you don’t need to detect russian, chinese, japanese or korean languages, you can use the EuroparlDetector available in the jlangdetect-europarl module. Note that you can still create your own language detector and register custom languages using the core module.
Keep in mind that this package requires SLF4J to be referenced.
JLangDetect is now available through Maven. To use it, you can add the following repository into your pom.xml file :
<repository>
<id>jlangdetect-googlecode</id>
<name>JLangDetect Maven repository</name>
<url>https://jlangdetect.googlecode.com/svn/repo</url>
</repository>
Then use the following dependency :
<dependency>
<groupId>me.champeau.jlangdetect</groupId>
<artifactId>jlangdetect-extra</artifactId>
<version>0.4</version>
</dependency>
As a last integration example, here is how to use it from Groovy, through a simple script :
@GrabResolver('https://jlangdetect.googlecode.com/svn/repo')
@Grab('me.champeau.jlangdetect:jlangdetect-extra:0.4')
import me.champeau.ld.UberLanguageDetector as ULD
ULD.instance.with {
assert detectLang('ceci est un petit texte en français') == 'fr'
assert detectLang('this is a text in english') == 'en'
}