@@ -5,48 +5,48 @@ |
||
| 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 | - |
|
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - foreach ($data['matches'] as $match) { |
|
| 36 | - if ($match['last-updated-by'] == '24aitor') { |
|
| 37 | - |
|
| 38 | - $this->translation = $match['translation']; |
|
| 39 | - $this->checkSave(); |
|
| 40 | - |
|
| 41 | - return; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $this->translation = $data['responseData']['translatedText']; |
|
| 46 | - $this->checkSave(); |
|
| 47 | - |
|
| 48 | - return; |
|
| 49 | - |
|
| 50 | - } |
|
| 51 | - } |
|
| 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 | + |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + foreach ($data['matches'] as $match) { |
|
| 36 | + if ($match['last-updated-by'] == '24aitor') { |
|
| 37 | + |
|
| 38 | + $this->translation = $match['translation']; |
|
| 39 | + $this->checkSave(); |
|
| 40 | + |
|
| 41 | + return; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $this->translation = $data['responseData']['translatedText']; |
|
| 46 | + $this->checkSave(); |
|
| 47 | + |
|
| 48 | + return; |
|
| 49 | + |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -19,12 +19,12 @@ discard block |
||
| 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 | } |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - foreach ($data['matches'] as $match) { |
|
| 36 | - if ($match['last-updated-by'] == '24aitor') { |
|
| 35 | + foreach ($data[ 'matches' ] as $match) { |
|
| 36 | + if ($match[ 'last-updated-by' ] == '24aitor') { |
|
| 37 | 37 | |
| 38 | - $this->translation = $match['translation']; |
|
| 38 | + $this->translation = $match[ 'translation' ]; |
|
| 39 | 39 | $this->checkSave(); |
| 40 | 40 | |
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $this->translation = $data['responseData']['translatedText']; |
|
| 45 | + $this->translation = $data[ 'responseData' ][ 'translatedText' ]; |
|
| 46 | 46 | $this->checkSave(); |
| 47 | 47 | |
| 48 | 48 | return; |