@@ -5,47 +5,47 @@ |
||
| 5 | 5 | class MymemoryTrans extends Translation |
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | - * Get translation from mymemory API. |
|
| 9 | - */ |
|
| 10 | - public function main() |
|
| 11 | - { |
|
| 12 | - $host = 'api.mymemory.translated.net'; |
|
| 13 | - |
|
| 14 | - // Check if host is online. |
|
| 15 | - if ($this->checkHost($host)) { |
|
| 16 | - |
|
| 17 | - // Host online |
|
| 18 | - $urlString = urlencode($this->string); |
|
| 19 | - $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
| 20 | - $data = json_decode($urldata, true); |
|
| 21 | - |
|
| 22 | - if ($data['responseStatus'] != 200) { |
|
| 23 | - if ($this->debug == true) { |
|
| 24 | - if ($data['responseStatus'] == 403) { |
|
| 25 | - $details = ($data['responseDetails']); |
|
| 26 | - } else { |
|
| 27 | - $details = $data['responseDetails']; |
|
| 28 | - } |
|
| 29 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - // Checking if any translation provides from 24aitor to use it |
|
| 36 | - foreach ($data['matches'] as $match) { |
|
| 37 | - if ($match['last-updated-by'] == '24aitor') { |
|
| 38 | - $this->translation = $match['translation']; |
|
| 39 | - $this->checkSave(); |
|
| 40 | - |
|
| 41 | - return; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $this->translation = $data['responseData']['translatedText']; |
|
| 46 | - $this->checkSave(); |
|
| 47 | - |
|
| 48 | - return; |
|
| 49 | - } |
|
| 50 | - } |
|
| 8 | + * Get translation from mymemory API. |
|
| 9 | + */ |
|
| 10 | + public function main() |
|
| 11 | + { |
|
| 12 | + $host = 'api.mymemory.translated.net'; |
|
| 13 | + |
|
| 14 | + // Check if host is online. |
|
| 15 | + if ($this->checkHost($host)) { |
|
| 16 | + |
|
| 17 | + // Host online |
|
| 18 | + $urlString = urlencode($this->string); |
|
| 19 | + $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
| 20 | + $data = json_decode($urldata, true); |
|
| 21 | + |
|
| 22 | + if ($data['responseStatus'] != 200) { |
|
| 23 | + if ($this->debug == true) { |
|
| 24 | + if ($data['responseStatus'] == 403) { |
|
| 25 | + $details = ($data['responseDetails']); |
|
| 26 | + } else { |
|
| 27 | + $details = $data['responseDetails']; |
|
| 28 | + } |
|
| 29 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + // Checking if any translation provides from 24aitor to use it |
|
| 36 | + foreach ($data['matches'] as $match) { |
|
| 37 | + if ($match['last-updated-by'] == '24aitor') { |
|
| 38 | + $this->translation = $match['translation']; |
|
| 39 | + $this->checkSave(); |
|
| 40 | + |
|
| 41 | + return; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $this->translation = $data['responseData']['translatedText']; |
|
| 46 | + $this->checkSave(); |
|
| 47 | + |
|
| 48 | + return; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $('#delete').click(function() { |
| 219 | 219 | var trans_id = $('.trans-id').val(); |
| 220 | 220 | <?php $url_route = Aitor24\Linker\Facades\Linker::route('laralang::deleteTrans'); |
| 221 | - ?> |
|
| 221 | + ?> |
|
| 222 | 222 | $.ajax({ |
| 223 | 223 | type: "POST", |
| 224 | 224 | url: "{{ $url_route }}", |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | $('#delete-all-button-confirm').click(function() { |
| 236 | 236 | <?php $url_route = Aitor24\Linker\Facades\Linker::route('laralang::deleteAll'); |
| 237 | - ?> |
|
| 237 | + ?> |
|
| 238 | 238 | $.ajax({ |
| 239 | 239 | type: "POST", |
| 240 | 240 | url: "{{ $url_route }}", |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $('#edit').click(function() { |
| 252 | 252 | var trans_id = $('.trans-id').val(); |
| 253 | 253 | <?php $url_route = Aitor24\Linker\Facades\Linker::route('laralang::editTrans'); |
| 254 | - ?> |
|
| 254 | + ?> |
|
| 255 | 255 | $.ajax({ |
| 256 | 256 | type: "POST", |
| 257 | 257 | url: "{{ $url_route }}", |
@@ -5,31 +5,31 @@ |
||
| 5 | 5 | class GoogleTrans extends Translation |
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | - * Get translation from Google. |
|
| 9 | - */ |
|
| 10 | - public function main() |
|
| 11 | - { |
|
| 12 | - $host = 'translate.googleapis.com'; |
|
| 8 | + * Get translation from Google. |
|
| 9 | + */ |
|
| 10 | + public function main() |
|
| 11 | + { |
|
| 12 | + $host = 'translate.googleapis.com'; |
|
| 13 | 13 | |
| 14 | - // Check if host is online. |
|
| 15 | - if ($this->checkHost($host)) { |
|
| 14 | + // Check if host is online. |
|
| 15 | + if ($this->checkHost($host)) { |
|
| 16 | 16 | |
| 17 | - // Host online |
|
| 18 | - $urlString = urlencode($this->string); |
|
| 19 | - $urldata = file_get_contents("https://translate.googleapis.com/translate_a/single?client=gtx&sl=$this->from&tl=$this->to&dt=t&q=$urlString"); |
|
| 20 | - $tr = $urldata; |
|
| 21 | - $tr = substr($tr, 3, -6); |
|
| 22 | - $tr = $tr.'["'; |
|
| 23 | - $tr = explode('],[', $tr); |
|
| 24 | - $trans = []; |
|
| 25 | - foreach ($tr as $tran) { |
|
| 26 | - $transl = explode('","', $tran); |
|
| 27 | - array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[0], 1)))); |
|
| 28 | - } |
|
| 29 | - $this->translation = trim(implode(' ', $trans)); |
|
| 30 | - $this->checkSave(); |
|
| 17 | + // Host online |
|
| 18 | + $urlString = urlencode($this->string); |
|
| 19 | + $urldata = file_get_contents("https://translate.googleapis.com/translate_a/single?client=gtx&sl=$this->from&tl=$this->to&dt=t&q=$urlString"); |
|
| 20 | + $tr = $urldata; |
|
| 21 | + $tr = substr($tr, 3, -6); |
|
| 22 | + $tr = $tr.'["'; |
|
| 23 | + $tr = explode('],[', $tr); |
|
| 24 | + $trans = []; |
|
| 25 | + foreach ($tr as $tran) { |
|
| 26 | + $transl = explode('","', $tran); |
|
| 27 | + array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[0], 1)))); |
|
| 28 | + } |
|
| 29 | + $this->translation = trim(implode(' ', $trans)); |
|
| 30 | + $this->checkSave(); |
|
| 31 | 31 | |
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - } |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | } |