@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('laralang_translations', function (Blueprint $table) { |
|
16 | + Schema::create('laralang_translations', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->string('translator'); |
19 | 19 | $table->string('string'); |
@@ -117,7 +117,7 @@ |
||
117 | 117 | if ($this->debug === true) { |
118 | 118 | $this->translation = "<font style='color:#00CC00;'>Translation loaded from DB</font>"; |
119 | 119 | } else { |
120 | - $this->translation = ($existing[0]->translation); |
|
120 | + $this->translation = ($existing[ 0 ]->translation); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return true; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $('#delete').click(function() { |
233 | 233 | var trans_id = $('.trans-id').val(); |
234 | 234 | <?php $url_route = url('/').'/'.config('laralang.default.prefix').'/delete'; |
235 | - ?> |
|
235 | + ?> |
|
236 | 236 | $.ajax({ |
237 | 237 | type: "POST", |
238 | 238 | url: "{{ $url_route }}", |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | $('#delete-all-button-confirm').click(function() { |
250 | 250 | <?php $url_route = url('/').'/'.config('laralang.default.prefix').'/delete/all'; |
251 | - ?> |
|
251 | + ?> |
|
252 | 252 | $.ajax({ |
253 | 253 | type: "POST", |
254 | 254 | url: "{{ $url_route }}", |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $('#edit').click(function() { |
266 | 266 | var trans_id = $('.trans-id').val(); |
267 | 267 | <?php $url_route = url('/').'/'.config('laralang.default.prefix').'/edit'; |
268 | - ?> |
|
268 | + ?> |
|
269 | 269 | $.ajax({ |
270 | 270 | type: "POST", |
271 | 271 | url: "{{ $url_route }}", |
@@ -250,7 +250,7 @@ |
||
250 | 250 | |
251 | 251 | $('#edit').click(function() { |
252 | 252 | var trans_id = $('.trans-id').val(); |
253 | - <?php $url_route = Aitor24\Linker\Facades\Linker::route('laralang::editTrans'); |
|
253 | + <?php $url_route = Aitor24\Linker\Facades\Linker::route('laralang::editTrans'); |
|
254 | 254 | ?> |
255 | 255 | $.ajax({ |
256 | 256 | type: "POST", |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | // Checking response status |
23 | 23 | |
24 | - if ($data['responseStatus'] != 200) { |
|
24 | + if ($data[ 'responseStatus' ] != 200) { |
|
25 | 25 | if ($this->debug === true) { |
26 | - $this->translation = "<font style='color:red;'>Error ".$data['responseStatus'].': '.$data['responseDetails'].'</font>'; |
|
26 | + $this->translation = "<font style='color:red;'>Error ".$data[ 'responseStatus' ].': '.$data[ 'responseDetails' ].'</font>'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | - $transObtained = $data['responseData']['translatedText']; |
|
32 | + $transObtained = $data[ 'responseData' ][ 'translatedText' ]; |
|
33 | 33 | |
34 | 34 | $this->translation = ucfirst(strtolower(trim(str_replace('*', ' ', $transObtained)))); |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $words = explode(' ', $transObtained); |
41 | 41 | foreach ($words as $word) { |
42 | 42 | if ($word != '') { |
43 | - if ($word[0] == '*') { |
|
43 | + if ($word[ 0 ] == '*') { |
|
44 | 44 | $errors = $errors.substr($word, 1).', '; |
45 | 45 | } |
46 | 46 | } |
@@ -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 | } |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
20 | 20 | $data = json_decode($urldata, true); |
21 | 21 | |
22 | - if ($data['responseStatus'] != 200) { |
|
22 | + if ($data[ 'responseStatus' ] != 200) { |
|
23 | 23 | if ($this->debug == true) { |
24 | - if ($data['responseStatus'] == 403) { |
|
25 | - $details = ($data['responseDetails']); |
|
24 | + if ($data[ 'responseStatus' ] == 403) { |
|
25 | + $details = ($data[ 'responseDetails' ]); |
|
26 | 26 | } else { |
27 | - $details = $data['responseDetails']; |
|
27 | + $details = $data[ 'responseDetails' ]; |
|
28 | 28 | } |
29 | 29 | $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
30 | 30 | } |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 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']; |
|
36 | + foreach ($data[ 'matches' ] as $match) { |
|
37 | + if ($match[ 'last-updated-by' ] == '24aitor') { |
|
38 | + $this->translation = $match[ 'translation' ]; |
|
39 | 39 | $this->checkSave(); |
40 | 40 | |
41 | 41 | return; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | - $this->translation = $data['responseData']['translatedText']; |
|
45 | + $this->translation = $data[ 'responseData' ][ 'translatedText' ]; |
|
46 | 46 | $this->checkSave(); |
47 | 47 | |
48 | 48 | return; |
@@ -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 = 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 = implode(' ', $trans); |
|
30 | + $this->checkSave(); |
|
31 | 31 | |
32 | - return; |
|
33 | - } |
|
34 | - } |
|
32 | + return; |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -21,10 +21,10 @@ |
||
21 | 21 | $tr = substr($tr, 3, -6); |
22 | 22 | $tr = $tr.'["'; |
23 | 23 | $tr = explode('],[', $tr); |
24 | - $trans = []; |
|
24 | + $trans = [ ]; |
|
25 | 25 | foreach ($tr as $tran) { |
26 | 26 | $transl = explode('","', $tran); |
27 | - array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[0], 1)))); |
|
27 | + array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[ 0 ], 1)))); |
|
28 | 28 | } |
29 | 29 | $this->translation = implode(' ', $trans); |
30 | 30 | $this->checkSave(); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public static function trans($string) |
20 | 20 | { |
21 | 21 | $translator = config('laralang.default.translator'); |
22 | - if (!in_array(config('laralang.default.translator'), ['apertium', 'mymemory', 'google'])) { |
|
22 | + if (!in_array(config('laralang.default.translator'), [ 'apertium', 'mymemory', 'google' ])) { |
|
23 | 23 | return "<font style='color:red;'>Laralang doesn't support $translator translator. Check config</font>"; |
24 | 24 | } else { |
25 | 25 | if (config('laralang.default.translator') == 'mymemory') { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function toLanguages() |
41 | 41 | { |
42 | - $locales = []; |
|
42 | + $locales = [ ]; |
|
43 | 43 | $translations = DB_Translation::distinct()->select('to_lang')->get(); |
44 | 44 | foreach ($translations as $object) { |
45 | 45 | array_push($locales, $object->to_lang); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function fromLanguages() |
57 | 57 | { |
58 | - $locales = []; |
|
58 | + $locales = [ ]; |
|
59 | 59 | $translations = DB_Translation::distinct()->select('from_lang')->get(); |
60 | 60 | foreach ($translations as $object) { |
61 | 61 | array_push($locales, $object->from_lang); |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (config('laralang.default.routes')) { |
4 | - Route::group(['middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers'], function () { |
|
4 | + Route::group([ 'middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers' ], function() { |
|
5 | 5 | Route::get('/login', 'LaralangController@showLogin')->name('login'); |
6 | 6 | Route::post('/login', 'LaralangController@login'); |
7 | 7 | if (config('laralang.default.api')) { |
8 | - Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () { |
|
8 | + Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() { |
|
9 | 9 | Route::post('/api/translate', 'LaralangController@apiTranslate')->name('apiTranslate'); |
10 | 10 | }); |
11 | 11 | } |
12 | - Route::group(['middleware' => 'laralang.middleware'], function () { |
|
13 | - Route::get('/', function () { |
|
12 | + Route::group([ 'middleware' => 'laralang.middleware' ], function() { |
|
13 | + Route::get('/', function() { |
|
14 | 14 | return redirect(Route('laralang::translations')); |
15 | 15 | })->name('home'); |
16 | 16 | Route::get('/translations', 'LaralangController@showTranslations')->name('translations'); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | Route::post('/edit', 'LaralangController@editTranslation'); |
26 | 26 | Route::get('/logout', 'LaralangController@logout')->name('logout'); |
27 | 27 | |
28 | - Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () { |
|
28 | + Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() { |
|
29 | 29 | Route::get('/api', 'LaralangController@api')->name('api'); |
30 | 30 | Route::get('/api/filter/from/{from_lang}/to/{to_lang}', 'LaralangController@apiFilterFromTo')->name('apiFilterFromTo'); |
31 | 31 | }); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function login(Request $request) |
24 | 24 | { |
25 | - session(['laralang.password' => Crypt::encrypt($request->input('password'))]); |
|
25 | + session([ 'laralang.password' => Crypt::encrypt($request->input('password')) ]); |
|
26 | 26 | if (Crypt::decrypt(session('laralang.password')) != config('laralang.default.password')) { |
27 | 27 | return redirect(Route('laralang::login')) |
28 | 28 | ->with('status', 'Invalid password'); |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | |
46 | 46 | public function showTranslationsFilter() |
47 | 47 | { |
48 | - return view('laralang::filter', ['languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages()]); |
|
48 | + return view('laralang::filter', [ 'languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages() ]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | public function translationsFilter(Request $request) |
52 | 52 | { |
53 | - return redirect(Linker::route('laralang::filterFromTo', [$request->from_lang, $request->to_lang])); |
|
53 | + return redirect(Linker::route('laralang::filterFromTo', [ $request->from_lang, $request->to_lang ])); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function showTranslationsFiltered($from_lang, $to_lang) |
57 | 57 | { |
58 | - return view('laralang::translations', ['from_lang' => $from_lang, 'to_lang' => $to_lang]); |
|
58 | + return view('laralang::translations', [ 'from_lang' => $from_lang, 'to_lang' => $to_lang ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function api() |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $translatedText = Laralang::trans($request->string)->to($request->to); |
69 | 69 | |
70 | - return ['translatedText' => strval($translatedText)]; |
|
70 | + return [ 'translatedText' => strval($translatedText) ]; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function apiFilterFromTo($from_lang, $to_lang) |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | } elseif ($to_lang == 'all') { |
79 | 79 | |
80 | 80 | //return translation where from_lang == $from |
81 | - return DB_Translation::where([['from_lang', $from_lang]])->get(); |
|
81 | + return DB_Translation::where([ [ 'from_lang', $from_lang ] ])->get(); |
|
82 | 82 | } elseif ($from_lang == 'all') { |
83 | 83 | |
84 | 84 | //return translation where to_lang == $to |
85 | - return DB_Translation::where([['to_lang', $to_lang]])->get(); |
|
85 | + return DB_Translation::where([ [ 'to_lang', $to_lang ] ])->get(); |
|
86 | 86 | } else { |
87 | 87 | |
88 | 88 | //return translation where from_lang == $from and to_lang == $to |
89 | - return DB_Translation::where([['from_lang', $from_lang], ['to_lang', $to_lang]])->get(); |
|
89 | + return DB_Translation::where([ [ 'from_lang', $from_lang ], [ 'to_lang', $to_lang ] ])->get(); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 |