1. Go to this page and download the library: Download pasyonis/translationhub 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/ */
pasyonis / translationhub example snippets
use Translationhub\Project;
use Translationhub\Config;
use Translationhub\Translation;
use Translationhub\Job;
\TranslationHub\Config::setEmail("your_email");
\TranslationHub\Config::setPassword("your_password");
$response = $projectApi->createProject(array(
"source_language_id"=>"tr",
"target_language_ids"=>"en,de",
"quality"=>"basic",
"callback_url"=>"http://mysite.com/postBack",
"project_url"=>"http://mysite.com",
"extras"=>array("id"=>"MyProjectId","type"=>"product description")
));
if($response->status=="error"){
//lets see what is the error
echo "There is an error : ".$response->errorMessage;
echo "Error details\n";
print_r($response->errors);
}
else {
//ok lets start to post my product description translations
$projectId = $response->project->id;
$response = $translationApi->postTranslation(array(
"project_id"=>$projectId,
"text_to_translate"=>"Merhaba, benim adım Aleyna. Merhaba, benim adım Aleyna. Nabersin ?", //there is two same sentences, i wonder if it will count it as once
"extras" => array("id"=>"MyDatabaseRowId","type"=>"Product Desc")
));
if($response->status=="error"){
echo "There is an error : ".$response->errorMessage;
echo "Error details\n";
print_r($response->errors);
}else {
echo "My Jobs Are, checkout word counts before analysis\n";
print_r($response->jobs);
}
// i will wait little bit to let them be analysed
echo "waiting to be analysed";
sleep(15);
//Lets get our job details and analysis results
$response = $projectApi->getTranslationJobs($projectId);
print_r($response);
if($response->status="success"){
foreach ($response->jobs as $job){
$wholeJob = $jobApi->getJob($job->id);
echo "job is \n";
print_r($wholeJob);
$analyseResult = $jobApi->getAnalysis($job->id);
echo "job analysis result\n";
print_r($analyseResult);
}
}
print_r($response);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.