PHP code example of chriskonnertz / deeply
1. Go to this page and download the library: Download chriskonnertz/deeply 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/ */
chriskonnertz / deeply example snippets
$deepLy = new ChrisKonnertz\DeepLy\DeepLy('your-api-key');
$translatedText = $deepLy->translate('Hello world!', 'DE');
echo $translatedText; // Prints "Hallo Welt!"
$deepLy = new ChrisKonnertz\DeepLy\DeepLy('your-api-key');
try {
$translatedText = $deepLy->translate('Hello world!', DeepLy::LANG_EN, DeepLy::LANG_AUTO);
echo $translatedText; // Prints "Hallo Welt!"
} catch (\Exception $exception) {
echo $exception->getMessage();
}
$languageCode = $deepLy->detectLanguage('Hello world!');
$glossaries = $deepLy->getGlossaries();
print_r($glossaries); // Prints an array with Glossary objects
$glossary = $deepLy->getGlossary('your-glossary-id');
print_r($glossary); // Prints a \stdClass
$entries = $deepLy->getGlossaryEntries('your-glossary-id');
print_r($entries); // Prints an array with string items
$glossary = $deepLy->createGlossary('test', 'de', 'en', ['Example DE' => 'Example EN']);
$deepLy->deleteGlossary('your-glossary-id');
$filename = __DIR__.'/test_document_original.pdf';
$result = $deepLy->uploadDocument($filename, 'DE');
var_dump($result);
$result = $deepLy->getDocumentState($result->documentId, $result->documentKey);
var_dump($result);
$deepLy->downloadDocument($documentId, $documentKey, 'test_document_translated.pdf');
$contents = $deepLy->downloadDocument($documentId, $documentKey);
$usage = $deepLy->usage(); // Returns an object of type "Usage"
echo $usage->characterCount.'/'.$usage->characterLimit
. ' characters ('.round($usage->characterQuota * 100).'%)';
ChrisKonnertz\DeepLy\Models\DocumentHandle Object
(
[documentId] => D014F316B7A173079074BE76F530F846
[documentKey] => 39FF8B10D20621096F23BF96CC103E12074727007C62963CF49AE8A9965D7695
)