PHP Classes

PHP Language Detection Library: Detect the language of a text using APILayer

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 137 All time: 9,252 This week: 524Up
Version License PHP version Categories
langlayer 1.0GNU General Publi...5Localization, PHP 5, Web services
Description 

Author

This class can detect the language of a text using APILayer.

It can send a HTTP request to the APILayer API Web server to detect the language of a given text string.

The class retrieves and decodes the response that indicates one or more of the 173 possible languages of the text with the respective probability of each language be the correct one.

Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 21 Up2 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
/*
example usage
languageLayer ver 1.0

You must get an API key from https://languagelayer.com/product
and enter it in the langlayer.class.php file
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//text to test
$text = 'Ich bin mir sicher, dass dies die Sprache Deutsch';

//instantiate the class
include('langlayer.class.php');
$lang = new languageLayer();

//get the response from the api
$lang->getResponse($text);

//check for reported error
if( $lang->errorCode ){
   
    die(
'error ('.$lang->errorCode.'): '.$lang->errorText);
   
}

//show the response object
var_dump($lang->response);
?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Plain text file langlayer.class.php Class Main Class
Accessible without login Plain text file license.txt Lic. License

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:137
This week:0
All time:9,252
This week:524Up