@@ -128,56 +128,56 @@ |
||
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Get translation from mymemory API. |
|
133 | - */ |
|
134 | - private function mymemoryTrans() |
|
135 | - { |
|
136 | - // Check if it can be translated from online sources. |
|
137 | - |
|
138 | - $host = 'api.mymemory.translated.net'; |
|
139 | - if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
140 | - |
|
141 | - // Host online |
|
142 | - $urlString = urlencode($this->string); |
|
143 | - $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
144 | - $json = file_get_contents($url); |
|
145 | - $data = json_decode($json); |
|
146 | - |
|
147 | - // Checking response status |
|
148 | - |
|
149 | - if ($data->responseStatus != 200) { |
|
150 | - if ($this->debug == true) { |
|
151 | - $details = $data->responseDetails; |
|
152 | - if ($data->responseStatus == 403) { |
|
153 | - $details = ($data->responseDetails); |
|
154 | - } |
|
155 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
156 | - } |
|
131 | + /** |
|
132 | + * Get translation from mymemory API. |
|
133 | + */ |
|
134 | + private function mymemoryTrans() |
|
135 | + { |
|
136 | + // Check if it can be translated from online sources. |
|
137 | + |
|
138 | + $host = 'api.mymemory.translated.net'; |
|
139 | + if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
140 | + |
|
141 | + // Host online |
|
142 | + $urlString = urlencode($this->string); |
|
143 | + $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
144 | + $json = file_get_contents($url); |
|
145 | + $data = json_decode($json); |
|
146 | + |
|
147 | + // Checking response status |
|
148 | + |
|
149 | + if ($data->responseStatus != 200) { |
|
150 | + if ($this->debug == true) { |
|
151 | + $details = $data->responseDetails; |
|
152 | + if ($data->responseStatus == 403) { |
|
153 | + $details = ($data->responseDetails); |
|
154 | + } |
|
155 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
156 | + } |
|
157 | 157 | |
158 | - return; |
|
159 | - } |
|
158 | + return; |
|
159 | + } |
|
160 | 160 | |
161 | - $transObtained = $data->responseData->translatedText; |
|
161 | + $transObtained = $data->responseData->translatedText; |
|
162 | 162 | |
163 | - $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
163 | + $this->translation = ucfirst(strtolower(trim($transObtained))); |
|
164 | 164 | |
165 | 165 | |
166 | - // Checking debug setting to determinate how to output translation |
|
166 | + // Checking debug setting to determinate how to output translation |
|
167 | 167 | |
168 | - if ($this->debug === true) { |
|
169 | - $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
170 | - } |
|
168 | + if ($this->debug === true) { |
|
169 | + $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
170 | + } |
|
171 | 171 | |
172 | - fclose($socket); |
|
172 | + fclose($socket); |
|
173 | 173 | |
174 | - return; |
|
175 | - } else { |
|
174 | + return; |
|
175 | + } else { |
|
176 | 176 | |
177 | - //host offline |
|
178 | - $this->hostDown(); |
|
179 | - } |
|
180 | - } |
|
177 | + //host offline |
|
178 | + $this->hostDown(); |
|
179 | + } |
|
180 | + } |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Get translation from apertium API. |