In a linguistic diversity on the internet report published by UNESCO in 2009 it is noticed a steady year-on-year decline in the percentage of webpages in English from 75% in 1998 to 45% in 2005. W3techs.com indicates today that there are 171 languages used on the web, 52% for English, 133 are used by less than 0.1% of the websites. However the distribution of language spoken in the world is completely different since English speakers represent only 5% !

Finding new businesses, new customers, new leads, require necessarily speaking new languages, or at least understanding the language that others are using. That’s why a library for language detection is very important, and could open doors to bunch of new opportunities. A great implementation of a language detection algorithm in PHP is available today, and comes with text samples used for training and detecting text in 106 languages.

A basic usage of the library :

use LanguageDetection\Language;

$ld = new Language;

$ld->detect('Mag het een onsje meer zijn?')->close();

Result will be :

Array
(
    "nl" => 0.66193548387097,
    "af" => 0.51338709677419,
    "br" => 0.49634408602151,
    "nb" => 0.48849462365591,
    "nn" => 0.48741935483871,
    "fy" => 0.47822580645161,
    "dk" => 0.47172043010753,
    "sv" => 0.46408602150538,
    "bi" => 0.46021505376344,
    "de" => 0.45903225806452,
    [...]
)

The library is trainable which means you can change, remove and add your own language files to it. If your language not supported, feel free to add your own language files.

More information and download on the github repository, released under an MIT license.

LEAVE A REPLY

Please enter your comment!
Please enter your name here