X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=GoogleTranslate.php;h=8d9c464ced5ba920a0a814abec9c43a52f6ab523;hp=e0f12543d96b275e2ac5ec0d0285c62c6d464154;hb=HEAD;hpb=f4f42a0f5cac9cdd211750a9d5adca8ec6f77114 diff --git a/GoogleTranslate.php b/GoogleTranslate.php index e0f12543..8d9c464c 100644 --- a/GoogleTranslate.php +++ b/GoogleTranslate.php @@ -20,12 +20,12 @@ class Pman_Core_GoogleTranslate extends Pman $this->authUser = $au; } - function get() { + function get($v, $opts=array()) { // for testing.. return $this->post(); } - function post() + function post($v) { $pc = HTML_FlexyFramework::get()->Pman_Core; if (empty($pc['googlekey'])) { @@ -39,11 +39,9 @@ class Pman_Core_GoogleTranslate extends Pman 'q' => $_REQUEST['text'], 'source' => $_REQUEST['src'], 'target' => $_REQUEST['dest'], - 'ie' => 'UTF-8', - 'oe' => 'UTF-8', + 'format' => 'text', ); - $url = 'https://www.googleapis.com/language/translate/v2'; $handle = curl_init(); @@ -61,16 +59,6 @@ class Pman_Core_GoogleTranslate extends Pman header("content-type: text/json"); echo $response; exit; - if(!empty($responseDecoded->error)){ - $this->jerr($responseDecoded->error->message); - } -// print_r($responseDecoded); - if(empty($responseDecoded->data->translations[0]->translatedText)){ - $this->jerr('does not have translated text.', print_r($responseDecoded, true)); - } -// var_dump($responseDecoded->data->translations[0]->translatedText); - $responseDecoded->data->translations[0]->translatedText = rawurldecode(str_replace(' ', '', $responseDecoded->data->translations[0]->translatedText)); - $this->jok($responseDecoded->data->translations[0]); }