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