PHP Detecting Language

Detecting Language via PHP

To detect a language via php first we need to create account on detectlanguage.

after successfully registration you will get a api-key.

use following link to download library.

then we need a php language file which will contain all language name and its short code.

download the language php file here.

now the final step we need to create a function to detect the langeuage.

require_once "language.php";

$key = "demo";
$world = "Buenos dias seƱor";

$languageCode = DetectLanguage::detect($word);  // detect the language
foreach($languageCode as &$code){
    $code->name = $arr[$code->language];

The output of above code will give following response

        "language": "es",
        "name": "Spanish"