@@ -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'); |
@@ -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; |
@@ -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", |
@@ -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 }}", |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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; |
@@ -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'); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public function showTranslationsFilter() |
52 | 52 | { |
53 | - return view('laralang::filter', ['languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages()]); |
|
53 | + return view('laralang::filter', [ 'languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages() ]); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function showTranslate() |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | |
67 | 67 | public function translationsFilter(Request $request) |
68 | 68 | { |
69 | - return redirect(Linker::route('laralang::filterFromTo', [$request->from_lang, $request->to_lang])); |
|
69 | + return redirect(Linker::route('laralang::filterFromTo', [ $request->from_lang, $request->to_lang ])); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function showTranslationsFiltered($from_lang, $to_lang) |
73 | 73 | { |
74 | - return view('laralang::translations', ['from_lang' => $from_lang, 'to_lang' => $to_lang]); |
|
74 | + return view('laralang::translations', [ 'from_lang' => $from_lang, 'to_lang' => $to_lang ]); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function api() |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $translatedText = Laralang::trans($request->string)->to($request->to); |
85 | 85 | |
86 | - return ['translatedText' => strval($translatedText)]; |
|
86 | + return [ 'translatedText' => strval($translatedText) ]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | public function apiFilterFromTo($from_lang, $to_lang) |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | } elseif ($to_lang == 'all') { |
95 | 95 | |
96 | 96 | //return translation where from_lang == $from |
97 | - return DB_Translation::where([['from_lang', $from_lang]])->get(); |
|
97 | + return DB_Translation::where([ [ 'from_lang', $from_lang ] ])->get(); |
|
98 | 98 | } elseif ($from_lang == 'all') { |
99 | 99 | |
100 | 100 | //return translation where to_lang == $to |
101 | - return DB_Translation::where([['to_lang', $to_lang]])->get(); |
|
101 | + return DB_Translation::where([ [ 'to_lang', $to_lang ] ])->get(); |
|
102 | 102 | } else { |
103 | 103 | |
104 | 104 | //return translation where from_lang == $from and to_lang == $to |
105 | - return DB_Translation::where([['from_lang', $from_lang], ['to_lang', $to_lang]])->get(); |
|
105 | + return DB_Translation::where([ [ 'from_lang', $from_lang ], [ 'to_lang', $to_lang ] ])->get(); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -1,15 +1,15 @@ 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 () { |
|
12 | + Route::group([ 'middleware' => 'laralang.middleware' ], function() { |
|
13 | 13 | Route::get('/', 'LaralangController@index')->name('index'); |
14 | 14 | Route::get('/translations', 'LaralangController@showTranslations')->name('translations'); |
15 | 15 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | Route::post('/edit', 'LaralangController@editTranslation')->name('editTrans'); |
27 | 27 | Route::get('/logout', 'LaralangController@logout')->name('logout'); |
28 | 28 | |
29 | - Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () { |
|
29 | + Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() { |
|
30 | 30 | Route::get('/api', 'LaralangController@api')->name('api'); |
31 | 31 | Route::get('/api/filter/from/{from_lang}/to/{to_lang}', 'LaralangController@apiFilterFromTo')->name('apiFilterFromTo'); |
32 | 32 | }); |
@@ -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 | } |
@@ -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 = trim(implode(' ', $trans)); |
30 | 30 | $this->checkSave(); |
@@ -35,7 +35,6 @@ |
||
35 | 35 | /** |
36 | 36 | * Generate files json for a specify package. |
37 | 37 | * |
38 | - * @param string $string |
|
39 | 38 | * |
40 | 39 | * @return object |
41 | 40 | */ |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return object |
18 | 18 | */ |
19 | - public static function trans($string, $vars = []) |
|
19 | + public static function trans($string, $vars = [ ]) |
|
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') { |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | private static function transArray($array, $lang) |
67 | 67 | { |
68 | 68 | foreach ($array as $var => $text) { |
69 | - $vars = []; |
|
69 | + $vars = [ ]; |
|
70 | 70 | if (is_array($text)) { |
71 | - $array[$var] = self::transArray($text, $lang); |
|
71 | + $array[ $var ] = self::transArray($text, $lang); |
|
72 | 72 | } else { |
73 | 73 | foreach (explode(' ', $text) as $word) { |
74 | 74 | if (strpos($word, ':') !== false && mb_substr($word, -1) != ':') { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | foreach ($vars as $key => $varreplace) { |
80 | 80 | $entry = str_replace($varreplace, '14741469'.$key, $entry); |
81 | 81 | } |
82 | - $array[$var] = self::trans($entry, $vars)->from('en')->to($lang)->load(false)->Save(false)->__toString(); |
|
82 | + $array[ $var ] = self::trans($entry, $vars)->from('en')->to($lang)->load(false)->Save(false)->__toString(); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public static function toLanguages() |
95 | 95 | { |
96 | - $locales = []; |
|
96 | + $locales = [ ]; |
|
97 | 97 | $translations = DB_Translation::distinct()->select('to_lang')->get(); |
98 | 98 | foreach ($translations as $object) { |
99 | 99 | array_push($locales, $object->to_lang); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public static function fromLanguages() |
111 | 111 | { |
112 | - $locales = []; |
|
112 | + $locales = [ ]; |
|
113 | 113 | $translations = DB_Translation::distinct()->select('from_lang')->get(); |
114 | 114 | foreach ($translations as $object) { |
115 | 115 | array_push($locales, $object->from_lang); |