@@ -5,37 +5,37 @@ |
||
5 | 5 | class MymemoryTrans extends Translation |
6 | 6 | { |
7 | 7 | /** |
8 | - * Get translation from mymemory API. |
|
9 | - */ |
|
10 | - public function main() |
|
11 | - { |
|
12 | - $host = 'api.mymemory.translated.net'; |
|
13 | - |
|
14 | - // Check if host is online. |
|
15 | - if ($this->checkHost($host)) { |
|
16 | - |
|
17 | - // Host online |
|
18 | - $urlString = urlencode($this->string); |
|
19 | - $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
20 | - $data = json_decode($urldata, true); |
|
21 | - |
|
22 | - if ($data['responseStatus'] != 200) { |
|
23 | - if ($this->debug == true) { |
|
24 | - if ($data['responseStatus'] == 403) { |
|
25 | - $details = ($data['responseDetails']); |
|
26 | - } else { |
|
27 | - $details = $data['responseDetails']; |
|
28 | - } |
|
29 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
30 | - } |
|
31 | - return; |
|
32 | - } |
|
33 | - |
|
34 | - $this->translation = $data['responseData']['translatedText']; |
|
35 | - |
|
36 | - $this->checkSave(); |
|
37 | - |
|
38 | - return; |
|
39 | - } |
|
40 | - } |
|
8 | + * Get translation from mymemory API. |
|
9 | + */ |
|
10 | + public function main() |
|
11 | + { |
|
12 | + $host = 'api.mymemory.translated.net'; |
|
13 | + |
|
14 | + // Check if host is online. |
|
15 | + if ($this->checkHost($host)) { |
|
16 | + |
|
17 | + // Host online |
|
18 | + $urlString = urlencode($this->string); |
|
19 | + $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
20 | + $data = json_decode($urldata, true); |
|
21 | + |
|
22 | + if ($data['responseStatus'] != 200) { |
|
23 | + if ($this->debug == true) { |
|
24 | + if ($data['responseStatus'] == 403) { |
|
25 | + $details = ($data['responseDetails']); |
|
26 | + } else { |
|
27 | + $details = $data['responseDetails']; |
|
28 | + } |
|
29 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
30 | + } |
|
31 | + return; |
|
32 | + } |
|
33 | + |
|
34 | + $this->translation = $data['responseData']['translatedText']; |
|
35 | + |
|
36 | + $this->checkSave(); |
|
37 | + |
|
38 | + return; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | } |
@@ -19,19 +19,19 @@ |
||
19 | 19 | $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
20 | 20 | $data = json_decode($urldata, true); |
21 | 21 | |
22 | - if ($data['responseStatus'] != 200) { |
|
22 | + if ($data[ 'responseStatus' ] != 200) { |
|
23 | 23 | if ($this->debug == true) { |
24 | - if ($data['responseStatus'] == 403) { |
|
25 | - $details = ($data['responseDetails']); |
|
24 | + if ($data[ 'responseStatus' ] == 403) { |
|
25 | + $details = ($data[ 'responseDetails' ]); |
|
26 | 26 | } else { |
27 | - $details = $data['responseDetails']; |
|
27 | + $details = $data[ 'responseDetails' ]; |
|
28 | 28 | } |
29 | 29 | $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
30 | 30 | } |
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | - $this->translation = $data['responseData']['translatedText']; |
|
34 | + $this->translation = $data[ 'responseData' ][ 'translatedText' ]; |
|
35 | 35 | |
36 | 36 | $this->checkSave(); |
37 | 37 |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | |
23 | 23 | // Checking response status |
24 | 24 | |
25 | - if ($data['responseStatus'] != 200) { |
|
25 | + if ($data[ 'responseStatus' ] != 200) { |
|
26 | 26 | if ($this->debug === true) { |
27 | - $this->translation = "<font style='color:red;'>Error ".$data['responseStatus'].': '.$data['responseDetails'] .'</font>'; |
|
27 | + $this->translation = "<font style='color:red;'>Error ".$data[ 'responseStatus' ].': '.$data[ 'responseDetails' ].'</font>'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | - $transObtained = $data['responseData']['translatedText']; |
|
33 | + $transObtained = $data[ 'responseData' ][ 'translatedText' ]; |
|
34 | 34 | |
35 | 35 | $this->translation = ucfirst(strtolower(trim(str_replace('*', ' ', $transObtained)))); |
36 | 36 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $words = explode(' ', $transObtained); |
42 | 42 | foreach ($words as $word) { |
43 | 43 | if ($word != '') { |
44 | - if ($word[0] == '*') { |
|
44 | + if ($word[ 0 ] == '*') { |
|
45 | 45 | $errors = $errors.substr($word, 1).', '; |
46 | 46 | } |
47 | 47 | } |