@@ -168,58 +168,58 @@ |
||
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Get translation from mymemory API. |
|
| 173 | - */ |
|
| 174 | - private function mymemoryTrans() |
|
| 175 | - { |
|
| 176 | - // Check if it can be translated from online sources. |
|
| 177 | - |
|
| 178 | - $host = 'api.mymemory.translated.net'; |
|
| 179 | - if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
| 180 | - |
|
| 181 | - // Host online |
|
| 182 | - $urlString = urlencode($this->string); |
|
| 183 | - $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
| 184 | - $json = file_get_contents($url); |
|
| 185 | - $data = json_decode($json); |
|
| 186 | - |
|
| 187 | - // Checking response status |
|
| 188 | - |
|
| 189 | - if ($data->responseStatus != 200) { |
|
| 190 | - if ($this->debug == true) { |
|
| 191 | - $details = $data->responseDetails; |
|
| 192 | - if ($data->responseStatus == 403) { |
|
| 193 | - $details = ($data->responseDetails); |
|
| 194 | - } |
|
| 195 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 196 | - } |
|
| 171 | + /** |
|
| 172 | + * Get translation from mymemory API. |
|
| 173 | + */ |
|
| 174 | + private function mymemoryTrans() |
|
| 175 | + { |
|
| 176 | + // Check if it can be translated from online sources. |
|
| 177 | + |
|
| 178 | + $host = 'api.mymemory.translated.net'; |
|
| 179 | + if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
| 180 | + |
|
| 181 | + // Host online |
|
| 182 | + $urlString = urlencode($this->string); |
|
| 183 | + $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
| 184 | + $json = file_get_contents($url); |
|
| 185 | + $data = json_decode($json); |
|
| 186 | + |
|
| 187 | + // Checking response status |
|
| 188 | + |
|
| 189 | + if ($data->responseStatus != 200) { |
|
| 190 | + if ($this->debug == true) { |
|
| 191 | + $details = $data->responseDetails; |
|
| 192 | + if ($data->responseStatus == 403) { |
|
| 193 | + $details = ($data->responseDetails); |
|
| 194 | + } |
|
| 195 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - return; |
|
| 199 | - } |
|
| 198 | + return; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | - $transObtained = $data->responseData->translatedText; |
|
| 202 | + $transObtained = $data->responseData->translatedText; |
|
| 203 | 203 | |
| 204 | - $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
| 204 | + $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
| 205 | 205 | |
| 206 | - $this->save(); |
|
| 206 | + $this->save(); |
|
| 207 | 207 | |
| 208 | - // Checking debug setting to determinate how to output translation |
|
| 208 | + // Checking debug setting to determinate how to output translation |
|
| 209 | 209 | |
| 210 | - if ($this->debug === true) { |
|
| 211 | - $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
| 212 | - } |
|
| 210 | + if ($this->debug === true) { |
|
| 211 | + $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | |
| 215 | - return; |
|
| 216 | - fclose($socket); |
|
| 217 | - } else { |
|
| 215 | + return; |
|
| 216 | + fclose($socket); |
|
| 217 | + } else { |
|
| 218 | 218 | |
| 219 | - //host offline |
|
| 220 | - $this->hostDown(); |
|
| 221 | - } |
|
| 222 | - } |
|
| 219 | + //host offline |
|
| 220 | + $this->hostDown(); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Get translation from apertium API. |