Completed
Push — master ( 30f395...1b2b07 )
by Aitor Riba
02:13
created
src/Migrations/2016_11_04_135240_laralang_translations.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Builder/ApertiumTrans.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
                     }
Please login to merge, or discard this patch.
src/Builder/MymemoryTrans.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,47 +5,47 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Builder/GoogleTrans.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Builder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Views/translations.blade.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@
 block discarded – undo
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",
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 }}",
Please login to merge, or discard this patch.
src/Controllers/LaralangController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Routes/web.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
25 25
             Route::post('/edit', 'LaralangController@editTranslation')->name('editTrans');
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
             });
Please login to merge, or discard this patch.
src/Builder/Translation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param string $string
25 25
      */
26
-    public function __construct($string, $vars = [])
26
+    public function __construct($string, $vars = [ ])
27 27
     {
28 28
         $this->translator = config('laralang.default.translator');
29 29
         $this->debug = config('laralang.default.debug');
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         if ($this->debug === true) {
121 121
             $this->translation = "<font style='color:#00CC00;'>Translation loaded from DB</font>";
122 122
         } else {
123
-            $this->translation = ($existing[0]->translation);
123
+            $this->translation = ($existing[ 0 ]->translation);
124 124
         }
125 125
 
126 126
         return true;
Please login to merge, or discard this patch.