Completed
Pull Request — master (#14)
by Aitor Riba
02:30 queued 44s
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/Routes/web.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 if (config('laralang.default.routes')) {
3
-    Route::group(['middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers'], function () {
3
+    Route::group([ 'middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers' ], function() {
4 4
         Route::get('/login', 'LaralangController@showLogin')->name('login');
5 5
         Route::post('/login', 'LaralangController@login');
6 6
 
7
-        Route::group(['middleware' => 'laralang.middleware'], function () {
8
-            Route::get('/', function () {
7
+        Route::group([ 'middleware' => 'laralang.middleware' ], function() {
8
+            Route::get('/', function() {
9 9
                 return redirect(Route('laralang::translations'));
10 10
             })->name('home');
11 11
             Route::get('/translations', 'LaralangController@showTranslations')->name('translations');
12 12
             Route::post('/delete', 'LaralangController@deleteTranslation')->name('delete');
13 13
             Route::post('/edit', 'LaralangController@editTranslation');
14 14
             Route::get('/logout', 'LaralangController@logout')->name('logout');
15
-            Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () {
15
+            Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() {
16 16
                 Route::get('/api', 'LaralangController@api')->name('api');
17 17
             });
18 18
         });
Please login to merge, or discard this patch.
src/Builder/Translation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Views/translations.blade.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 }}",
Please login to merge, or discard this patch.
src/Builder/MymemoryTrans.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 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
                  }
31 31
                  return;
32 32
              }
33 33
 
34
-             $this->translation = $data['responseData']['translatedText'];
34
+             $this->translation = $data[ 'responseData' ][ 'translatedText' ];
35 35
 
36 36
              $this->checkSave();
37 37
 
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -5,38 +5,38 @@
 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
-             $this->translation = $data['responseData']['translatedText'];
36
-
37
-             $this->checkSave();
38
-
39
-             return;
40
-         }
41
-     }
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
+                $this->translation = $data['responseData']['translatedText'];
36
+
37
+                $this->checkSave();
38
+
39
+                return;
40
+            }
41
+        }
42 42
 }
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.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public static function trans($string)
19 19
     {
20 20
         $translator = config('laralang.default.translator');
21
-        if (!in_array(config('laralang.default.translator'), ['apertium', 'mymemory'])) {
21
+        if (!in_array(config('laralang.default.translator'), [ 'apertium', 'mymemory' ])) {
22 22
             return "<font style='color:red;'>Laralang doesn't support $translator translator. Check config</font>";
23 23
         } else {
24 24
             if (config('laralang.default.translator') == 'mymemory') {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public static function toLanguages()
38 38
     {
39
-        $locales = [];
39
+        $locales = [ ];
40 40
         $translations = DB_Translation::distinct()->select('to_lang')->get();
41 41
         foreach ($translations as $object) {
42 42
             array_push($locales, $object->to_lang);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public static function fromLanguages()
54 54
     {
55
-        $locales = [];
55
+        $locales = [ ];
56 56
         $translations = DB_Translation::distinct()->select('from_lang')->get();
57 57
         foreach ($translations as $object) {
58 58
             array_push($locales, $object->from_lang);
@@ -68,6 +68,6 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public static function allLanguages()
70 70
     {
71
-        return ['English' => 'en', 'Spanish' => 'es', 'Catalan' => 'ca', 'Portuguese' => 'pt', 'Chinese' => 'zh', 'Japanese' => 'ja', 'German' => 'de', 'French' => 'fr'];
71
+        return [ 'English' => 'en', 'Spanish' => 'es', 'Catalan' => 'ca', 'Portuguese' => 'pt', 'Chinese' => 'zh', 'Japanese' => 'ja', 'German' => 'de', 'French' => 'fr' ];
72 72
     }
73 73
 }
Please login to merge, or discard this patch.
src/Controllers/LaralangController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function login(Request $request)
23 23
     {
24
-        session(['laralang.password' => Crypt::encrypt($request->input('password'))]);
24
+        session([ 'laralang.password' => Crypt::encrypt($request->input('password')) ]);
25 25
         if (Crypt::decrypt(session('laralang.password')) != config('laralang.default.password')) {
26 26
             return redirect(Route('laralang::login'))
27 27
             ->with('status', 'Invalid password');
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function showTranslationsFilter()
46 46
     {
47
-        return view('laralang::filter', ['languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages()]);
47
+        return view('laralang::filter', [ 'languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages() ]);
48 48
     }
49 49
 
50 50
     public function translationsFilter(Request $request)
51 51
     {
52
-        return redirect()->route('laralang::filterFromTo', [$request->from_lang, $request->to_lang]);
52
+        return redirect()->route('laralang::filterFromTo', [ $request->from_lang, $request->to_lang ]);
53 53
     }
54 54
 
55 55
     public function showTranslationsFiltered($from_lang, $to_lang)
56 56
     {
57
-        return view('laralang::translations', ['from_lang' => $from_lang, 'to_lang' => $to_lang]);
57
+        return view('laralang::translations', [ 'from_lang' => $from_lang, 'to_lang' => $to_lang ]);
58 58
     }
59 59
 
60 60
     public function api()
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
         } elseif ($to_lang == 'all') {
71 71
 
72 72
             //return translation where from_lang == $from
73
-            return DB_Translation::where([['from_lang', $from_lang]])->get();
73
+            return DB_Translation::where([ [ 'from_lang', $from_lang ] ])->get();
74 74
         } elseif ($from_lang == 'all') {
75 75
 
76 76
             //return translation where to_lang == $to
77
-            return DB_Translation::where([['to_lang', $to_lang]])->get();
77
+            return DB_Translation::where([ [ 'to_lang', $to_lang ] ])->get();
78 78
         } else {
79 79
 
80 80
             //return translation where from_lang == $from and to_lang == $to
81
-            return DB_Translation::where([['from_lang', $from_lang], ['to_lang', $to_lang]])->get();
81
+            return DB_Translation::where([ [ 'from_lang', $from_lang ], [ 'to_lang', $to_lang ] ])->get();
82 82
         }
83 83
     }
84 84
 
Please login to merge, or discard this patch.