@@ -5,44 +5,44 @@ |
||
5 | 5 | class MymemoryTrans extends Translation |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Get translation from mymemory API. |
|
10 | - */ |
|
11 | - public function main() |
|
12 | - { |
|
13 | - $host = 'api.mymemory.translated.net'; |
|
8 | + /** |
|
9 | + * Get translation from mymemory API. |
|
10 | + */ |
|
11 | + public function main() |
|
12 | + { |
|
13 | + $host = 'api.mymemory.translated.net'; |
|
14 | 14 | |
15 | - // Check if host is online. |
|
16 | - if ($this->checkHost($host)) { |
|
15 | + // Check if host is online. |
|
16 | + if ($this->checkHost($host)) { |
|
17 | 17 | |
18 | - // Host online |
|
19 | - $urlString = urlencode($this->string); |
|
20 | - $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
21 | - $json = file_get_contents($url); |
|
22 | - $data = json_decode($json); |
|
18 | + // Host online |
|
19 | + $urlString = urlencode($this->string); |
|
20 | + $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
21 | + $json = file_get_contents($url); |
|
22 | + $data = json_decode($json); |
|
23 | 23 | |
24 | - // Checking response status |
|
25 | - if ($data->responseStatus != 200) { |
|
26 | - if ($this->debug == true) { |
|
27 | - $details = $data->responseDetails; |
|
28 | - if ($data->responseStatus == 403) { |
|
29 | - $details = ($data->responseDetails); |
|
30 | - } |
|
31 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
32 | - } |
|
24 | + // Checking response status |
|
25 | + if ($data->responseStatus != 200) { |
|
26 | + if ($this->debug == true) { |
|
27 | + $details = $data->responseDetails; |
|
28 | + if ($data->responseStatus == 403) { |
|
29 | + $details = ($data->responseDetails); |
|
30 | + } |
|
31 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
32 | + } |
|
33 | 33 | |
34 | - return; |
|
35 | - } |
|
34 | + return; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - $transObtained = $data->responseData->translatedText; |
|
38 | + $transObtained = $data->responseData->translatedText; |
|
39 | 39 | |
40 | - $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
40 | + $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
41 | 41 | |
42 | - $this->checkSave(); |
|
42 | + $this->checkSave(); |
|
43 | 43 | |
44 | - return; |
|
45 | - } |
|
46 | - } |
|
44 | + return; |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -151,10 +151,10 @@ |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * This fuction is called to know the status of host, and it would set translation if debug is true. |
|
155 | - * |
|
156 | - * @param string $host |
|
157 | - */ |
|
154 | + * This fuction is called to know the status of host, and it would set translation if debug is true. |
|
155 | + * |
|
156 | + * @param string $host |
|
157 | + */ |
|
158 | 158 | public function checkHost($host) |
159 | 159 | { |
160 | 160 | $socket = @fsockopen($host, 80, $errno, $errstr, 30); |
@@ -5,14 +5,14 @@ |
||
5 | 5 | class Exception extends Translation |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Get translation from mymemory API. |
|
10 | - */ |
|
11 | - public function main() |
|
12 | - { |
|
13 | - // Check if it can be translated from online sources. |
|
8 | + /** |
|
9 | + * Get translation from mymemory API. |
|
10 | + */ |
|
11 | + public function main() |
|
12 | + { |
|
13 | + // Check if it can be translated from online sources. |
|
14 | 14 | |
15 | - return; |
|
16 | - } |
|
15 | + return; |
|
16 | + } |
|
17 | 17 | |
18 | 18 | } |