@@ -176,58 +176,58 @@ |
||
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Get translation from mymemory API. |
|
| 181 | - */ |
|
| 182 | - private function mymemoryTrans() |
|
| 183 | - { |
|
| 184 | - // Check if it can be translated from online sources. |
|
| 185 | - |
|
| 186 | - $host = 'api.mymemory.translated.net'; |
|
| 187 | - if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
| 188 | - |
|
| 189 | - // Host online |
|
| 190 | - $urlString = urlencode($this->string); |
|
| 191 | - $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
| 192 | - $json = file_get_contents($url); |
|
| 193 | - $data = json_decode($json); |
|
| 194 | - |
|
| 195 | - // Checking response status |
|
| 196 | - |
|
| 197 | - if ($data->responseStatus != 200) { |
|
| 198 | - if ($this->debug == true) { |
|
| 199 | - $details = $data->responseDetails; |
|
| 200 | - if ($data->responseStatus == 403) { |
|
| 201 | - $details = ($data->responseDetails); |
|
| 202 | - } |
|
| 203 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 204 | - } |
|
| 179 | + /** |
|
| 180 | + * Get translation from mymemory API. |
|
| 181 | + */ |
|
| 182 | + private function mymemoryTrans() |
|
| 183 | + { |
|
| 184 | + // Check if it can be translated from online sources. |
|
| 185 | + |
|
| 186 | + $host = 'api.mymemory.translated.net'; |
|
| 187 | + if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) { |
|
| 188 | + |
|
| 189 | + // Host online |
|
| 190 | + $urlString = urlencode($this->string); |
|
| 191 | + $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to"; |
|
| 192 | + $json = file_get_contents($url); |
|
| 193 | + $data = json_decode($json); |
|
| 194 | + |
|
| 195 | + // Checking response status |
|
| 196 | + |
|
| 197 | + if ($data->responseStatus != 200) { |
|
| 198 | + if ($this->debug == true) { |
|
| 199 | + $details = $data->responseDetails; |
|
| 200 | + if ($data->responseStatus == 403) { |
|
| 201 | + $details = ($data->responseDetails); |
|
| 202 | + } |
|
| 203 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - return; |
|
| 207 | - } |
|
| 206 | + return; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | - $transObtained = $data->responseData->translatedText; |
|
| 210 | + $transObtained = $data->responseData->translatedText; |
|
| 211 | 211 | |
| 212 | - $this->translation = utf8_decode(ucfirst(strtolower(trim($transObtained)))); |
|
| 212 | + $this->translation = utf8_decode(ucfirst(strtolower(trim($transObtained)))); |
|
| 213 | 213 | |
| 214 | - $this->save(); |
|
| 214 | + $this->save(); |
|
| 215 | 215 | |
| 216 | - // Checking debug setting to determinate how to output translation |
|
| 216 | + // Checking debug setting to determinate how to output translation |
|
| 217 | 217 | |
| 218 | - if ($this->debug === true) { |
|
| 219 | - $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
| 220 | - } |
|
| 218 | + if ($this->debug === true) { |
|
| 219 | + $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>'; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | |
| 223 | - return; |
|
| 224 | - fclose($socket); |
|
| 225 | - } else { |
|
| 223 | + return; |
|
| 224 | + fclose($socket); |
|
| 225 | + } else { |
|
| 226 | 226 | |
| 227 | - //host offline |
|
| 228 | - $this->hostDown(); |
|
| 229 | - } |
|
| 230 | - } |
|
| 227 | + //host offline |
|
| 228 | + $this->hostDown(); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * Get translation from apertium API. |
@@ -156,13 +156,13 @@ |
||
| 156 | 156 | $( function() { |
| 157 | 157 | $('#delete').click(function() { |
| 158 | 158 | <?php $url_route = url('/').'/'.config('laralang.default.prefix').'/delete'; |
| 159 | - ?> |
|
| 159 | + ?> |
|
| 160 | 160 | $.get("{{ $url_route }}"+'/'+$('.trans-id').val()); |
| 161 | 161 | }); |
| 162 | 162 | $('#edit').click(function() { |
| 163 | 163 | var translation = $('.input-trans').val(); |
| 164 | 164 | <?php $url_route = url('/').'/'.config('laralang.default.prefix').'/edit'; |
| 165 | - ?> |
|
| 165 | + ?> |
|
| 166 | 166 | $.get("{{ $url_route }}"+'/'+$('.trans-id').val()+'/'+translation); |
| 167 | 167 | }); |
| 168 | 168 | |