clipbucket/upload/includes/classes/translation.class.php

58 lines
1.6 KiB
PHP
Raw Normal View History

<?php
2016-05-25 17:10:29 +05:00
global $lang_obj;
require_once 'GTvendor/autoload.php';
use Stichoza\GoogleTranslate\TranslateClient;
$transClient = new TranslateClient(); // Default is from 'auto' to 'en'
2016-05-25 17:10:29 +05:00
class GoogleTranslator
{
/**
* Get access token
*
* @return string
*/
public function get_access_token() {
return false;
}
/**
* Translate text to a specified language
*
* @param string $text
* @param string $to language to be translated to
* @param string $from language of text
* @return string Translated text
*/
public function translate($text, $to, $from = 'en') {
global $transClient;
$transClient->setSource($from); // Translate from English
$transClient->setTarget($to); // Translate to Georgian
$transClient->setUrlBase('http://translate.google.cn/translate_a/single'); // Set Google Translate URL base (This is not necessary, only for some countries)
$phraseTranslated = $transClient->translate($text);
return $phraseTranslated;
}
/**
* Translate text to specified languages
*
* @param string $text
* @param string $from language of text
* @param array $tos languages to be translated to
* @return array Translations of the text to given languages
*/
2016-05-25 17:10:29 +05:00
public function multiTranslate($text, $from, $tos) {
return false;
}
/**
* Detect the language of a given text
*
* @param String $text
* @return String Language of text
*/
2016-05-25 17:10:29 +05:00
public function detectLang($text) {
return false;
}
}
?>