1. Go to this page and download the library: Download benmorel/languagelayer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
benmorel / languagelayer example snippets
use BenMorel\LanguageLayer\LanguageLayerClient;
$client = new LanguageLayerClient('YOUR API KEY');
$results = $client->detectLanguages('Some text. Try more than a few words for accurate detection.');
foreach ($results as $result) {
if ($result->isReliableResult()) {
echo $result->getLanguageCode();
}
}
$languageCode = $client->detectLanguage('Some text. Try more than a few words for accurate detection.');
use BenMorel\LanguageLayer\LanguageDetectionException;
// …
try {
$languageCode = $client->detectLanguage('...');
catch (LanguageDetectionException $exception) {
// deal with it.
}
try {
$languageCode = $client->detectLanguage('...');
} catch (LanguageDetectionException $exception) {
switch ($exception->getType()) {
case 'invalid_access_key':
case 'usage_limit_reached':
// report the error!
break;
case 'rate_limit_reached':
// slow down!
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.