@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function boot() |
28 | 28 | { |
29 | - Blade::directive('translate', function ($expression) { |
|
29 | + Blade::directive('translate', function($expression) { |
|
30 | 30 | |
31 | 31 | $expression = $this->stripParentheses($expression); |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | } |
36 | 36 | ); |
37 | 37 | |
38 | - Blade::directive('t', function ($expression) { |
|
38 | + Blade::directive('t', function($expression) { |
|
39 | 39 | |
40 | 40 | $expression = $this->stripParentheses($expression); |
41 | 41 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | DB::beginTransaction(); |
29 | 29 | |
30 | 30 | // Create table for storing roles |
31 | - Schema::create('translation_identifiers', function (Blueprint $table) |
|
31 | + Schema::create('translation_identifiers', function(Blueprint $table) |
|
32 | 32 | { |
33 | 33 | $table->increments('id')->unique(); |
34 | 34 | $table->text('identifier'); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | }); |
44 | 44 | |
45 | 45 | // Create table for storing roles |
46 | - Schema::create('translations', function (Blueprint $table) |
|
46 | + Schema::create('translations', function(Blueprint $table) |
|
47 | 47 | { |
48 | 48 | $table->integer('translation_identifier_id')->unsigned(); |
49 | 49 | $table->foreign('translation_identifier_id')->references('id')->on('translation_identifiers')->onDelete('no action')->onUpdate('no action'); |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * @license http://opensource.org/licenses/MIT MIT |
8 | 8 | */ |
9 | 9 | |
10 | -if (! Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
11 | - Route::group(['prefix' => 'translator'], function () { |
|
10 | +if (!Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
11 | + Route::group(['prefix' => 'translator'], function() { |
|
12 | 12 | Route::get('/test', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@test')->name('translator.test'); |
13 | 13 | |
14 | - Route::group(['prefix' => 'admin'], function () { |
|
14 | + Route::group(['prefix' => 'admin'], function() { |
|
15 | 15 | Route::get('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@index')->name('translator.admin'); |
16 | 16 | Route::post('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@postIdentifier')->name('translator.post.admin'); |
17 | 17 | Route::get('/{id}', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@edit')->where('id', '[0-9]+')->name('translator.admin.edit'); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $keys = []; |
190 | 190 | if (is_array($parameters)) { |
191 | - foreach($parameters as $key => $value) { |
|
191 | + foreach ($parameters as $key => $value) { |
|
192 | 192 | $keys[] = $key; |
193 | 193 | } |
194 | 194 | } |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | // When using file Cache, adding the Identifier to the Database will not add it to file Cache! |
207 | 207 | $this->aHandler[$this->locale]->refreshCache(); |
208 | 208 | } |
209 | - $this->log('The translation string "'.$identifier.'" will be written to the Database', 'notice'); |
|
209 | + $this->log('The translation string "' . $identifier . '" will be written to the Database', 'notice'); |
|
210 | 210 | } else { |
211 | - $this->log('The translation string "'.$identifier.'" is already in the Database!', 'warning'); |
|
211 | + $this->log('The translation string "' . $identifier . '" is already in the Database!', 'warning'); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | foreach ($parameters as $key => $parameter) { |
238 | 238 | // If the string (e.g "{name}") is not specified within the "parameters" array it won't be replaced! |
239 | - $translation = str_replace("{".$key."}", $parameter, $translation); |
|
239 | + $translation = str_replace("{" . $key . "}", $parameter, $translation); |
|
240 | 240 | } |
241 | 241 | return $translation; |
242 | 242 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | protected function returnMissingTranslation($identifier, $locale) |
253 | 253 | { |
254 | 254 | if (config('app.env') !== 'production') { |
255 | - return '<'.$identifier.':'.$locale.'>'; |
|
255 | + return '<' . $identifier . ':' . $locale . '>'; |
|
256 | 256 | } |
257 | 257 | return $identifier; |
258 | 258 | } |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | $found_locales = []; |
305 | 305 | |
306 | 306 | foreach ($avail_locales as $avail_locale) { |
307 | - if (strpos($avail_locale, $locale) !== false){ |
|
307 | + if (strpos($avail_locale, $locale) !== false) { |
|
308 | 308 | $found_locales[] = $avail_locale; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | - if (in_array($default_locale, $found_locales) || count($found_locales) == 0){ |
|
313 | - $message = 'Locale "'.$locale.'" was not found! Falling back to default locale "'.$default_locale.'"'; |
|
312 | + if (in_array($default_locale, $found_locales) || count($found_locales) == 0) { |
|
313 | + $message = 'Locale "' . $locale . '" was not found! Falling back to default locale "' . $default_locale . '"'; |
|
314 | 314 | $locale = $default_locale; |
315 | 315 | |
316 | 316 | } else { |
317 | - $message = 'Locale "'.$locale.'" was not found! Falling back to similar locale "'.$found_locales[0].'"'; |
|
317 | + $message = 'Locale "' . $locale . '" was not found! Falling back to similar locale "' . $found_locales[0] . '"'; |
|
318 | 318 | $locale = $found_locales[0]; |
319 | 319 | } |
320 | 320 |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | 'js' => '/\$filter\(\'translate\'\)\(\'(?\'identifier\'.*?)\'\)/' |
77 | 77 | ]; |
78 | 78 | |
79 | - foreach($folders as $folder) { |
|
80 | - $aFiles = array_merge($aFiles, File::allFiles(base_path().'/'.$folder)); |
|
79 | + foreach ($folders as $folder) { |
|
80 | + $aFiles = array_merge($aFiles, File::allFiles(base_path() . '/' . $folder)); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | TranslatorFacade::setLocale('de_DE'); |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | $num_files = count($aFiles); |
86 | 86 | |
87 | 87 | $this->bar = $this->output->createProgressBar($num_files); |
88 | - $this->bar->setMessage('Analyzing '.$num_files.' files'); |
|
88 | + $this->bar->setMessage('Analyzing ' . $num_files . ' files'); |
|
89 | 89 | $this->bar->setFormat('very_verbose'); |
90 | 90 | |
91 | 91 | foreach ($aFiles as $file) { |
92 | 92 | |
93 | 93 | $extension = $file->getExtension(); |
94 | 94 | |
95 | - if(in_array($extension, $valid_extensions)) { |
|
95 | + if (in_array($extension, $valid_extensions)) { |
|
96 | 96 | $content = file_get_contents($file); |
97 | 97 | |
98 | 98 | foreach ($regexes as $key => $regex) { |
99 | 99 | preg_match_all($regex, $content, $result, PREG_SET_ORDER); |
100 | 100 | |
101 | - if(!empty($result[0])) { |
|
101 | + if (!empty($result[0])) { |
|
102 | 102 | $this->addMissing($result, $key); |
103 | 103 | } |
104 | 104 | } |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | ['Num', 'Translations...'], |
115 | 115 | [ |
116 | 116 | [$this->found_identifier, "Found"], |
117 | - [$this->new_identifier, "New"], |
|
118 | - [$this->dupl_identifier, "Duplicates"], |
|
117 | + [$this->new_identifier, "New"], |
|
118 | + [$this->dupl_identifier, "Duplicates"], |
|
119 | 119 | [$this->found_parameters, "With Parameters"], |
120 | - [$this->found_invalid, "Invalid"], |
|
120 | + [$this->found_invalid, "Invalid"], |
|
121 | 121 | ] |
122 | 122 | ); |
123 | 123 | |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | $parameter_string = substr($parameter_string, 1, -1); |
149 | 149 | } |
150 | 150 | |
151 | - $parameter_array = explode(",",$parameter_string); |
|
151 | + $parameter_array = explode(",", $parameter_string); |
|
152 | 152 | $parameters = array(); |
153 | 153 | |
154 | - foreach($parameter_array as $parameter) { |
|
155 | - $parameter = explode("=>",$parameter); |
|
154 | + foreach ($parameter_array as $parameter) { |
|
155 | + $parameter = explode("=>", $parameter); |
|
156 | 156 | |
157 | - $key = str_replace([" ", "'"],"", $parameter[0]); |
|
158 | - $value = str_replace([" ", "'"],"", $parameter[1]); |
|
157 | + $key = str_replace([" ", "'"], "", $parameter[0]); |
|
158 | + $value = str_replace([" ", "'"], "", $parameter[1]); |
|
159 | 159 | |
160 | 160 | $parameters[$key] = $value; |
161 | 161 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | $this->found_parameters++; |
164 | 164 | } |
165 | 165 | |
166 | - if(!isset($aTranslations[$identifier])) { |
|
166 | + if (!isset($aTranslations[$identifier])) { |
|
167 | 167 | $aTranslations[$identifier] = TranslatorFacade::hasIdentifier($identifier); |
168 | 168 | |
169 | 169 | if (!$aTranslations[$identifier]) { |
170 | 170 | TranslatorFacade::addMissingIdentifier($identifier, $parameters, $group); |
171 | 171 | $this->bar->clear(); |
172 | - $this->info('Adding: "'.$identifier.'" to database'); |
|
172 | + $this->info('Adding: "' . $identifier . '" to database'); |
|
173 | 173 | $this->bar->display(); |
174 | 174 | $this->new_identifier++; |
175 | 175 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $this->dupl_identifier++; |
178 | 178 | } |
179 | 179 | |
180 | - } catch(\Exception $e){ |
|
180 | + } catch (\Exception $e) { |
|
181 | 181 | $this->bar->clear(); |
182 | - $this->info($identifier.' '.strlen($identifier)); |
|
182 | + $this->info($identifier . ' ' . strlen($identifier)); |
|
183 | 183 | $this->info($e->getMessage()); |
184 | 184 | $this->line(''); |
185 | 185 | $this->bar->display(); |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - $file_path = TranslatorFacade::getConfigValue('cache_path').$locale.'/'; |
|
62 | + $file_path = TranslatorFacade::getConfigValue('cache_path') . $locale . '/'; |
|
63 | 63 | |
64 | 64 | $groups = $this->getGroups(); |
65 | 65 | $translations = $this->loadFromDB($locale); |
66 | 66 | |
67 | 67 | if (!file_exists($file_path)) { |
68 | - $this->alert("The defined cache folder (".$file_path.") does not exists."); |
|
68 | + $this->alert("The defined cache folder (" . $file_path . ") does not exists."); |
|
69 | 69 | if (!$this->confirm('Do you want to create it now?')) { |
70 | 70 | return; |
71 | 71 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | if (!empty($array)) { |
91 | - $file_name = $file_path.$group.'.json'; |
|
91 | + $file_name = $file_path . $group . '.json'; |
|
92 | 92 | file_put_contents($file_name, json_encode($array)); |
93 | 93 | } |
94 | 94 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | $trans_identifier = new TranslationIdentifier(); |
116 | 116 | |
117 | - $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) |
|
117 | + $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale) |
|
118 | 118 | { |
119 | 119 | return $item->where('locale', $locale); |
120 | 120 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function register() |
26 | 26 | { |
27 | - $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
|
27 | + $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator'); |
|
28 | 28 | |
29 | - $this->app->singleton('Translator', function () { |
|
29 | + $this->app->singleton('Translator', function() { |
|
30 | 30 | return new Translator(); |
31 | 31 | } |
32 | 32 | ); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | 'config' |
44 | 44 | ); |
45 | 45 | |
46 | - $this->loadMigrationsFrom(__DIR__.'/../migrations/'); |
|
47 | - $this->loadRoutesFrom(__DIR__.'/../resources/routes.php'); |
|
48 | - $this->loadViewsFrom(__DIR__.'/../resources/views', 'translator'); |
|
46 | + $this->loadMigrationsFrom(__DIR__ . '/../migrations/'); |
|
47 | + $this->loadRoutesFrom(__DIR__ . '/../resources/routes.php'); |
|
48 | + $this->loadViewsFrom(__DIR__ . '/../resources/views', 'translator'); |
|
49 | 49 | |
50 | 50 | if ($this->app->runningInConsole()) { |
51 | 51 | $this->commands([ |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $query = TranslationIdentifier::with('translations'); |
36 | 36 | |
37 | 37 | if ($locale != '') { |
38 | - $query = $query->whereDoesntHave('translations', function ($query) use ($locale) |
|
38 | + $query = $query->whereDoesntHave('translations', function($query) use ($locale) |
|
39 | 39 | { |
40 | 40 | $query->where('translations.locale', 'like', $locale); |
41 | 41 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | if ($search != '') { |
46 | - $query = $query->where(function ($query) use ($search) { |
|
47 | - $query ->where('identifier', 'LIKE', '%'.$search.'%') |
|
48 | - ->orWhere('parameters', 'LIKE', '%'.$search.'%') |
|
49 | - ->orWhere('group', 'LIKE', '%'.$search.'%') |
|
50 | - ->orWhere('page_name', 'LIKE', '%'.$search.'%') |
|
51 | - ->orWhere('description','LIKE', '%'.$search.'%'); |
|
46 | + $query = $query->where(function($query) use ($search) { |
|
47 | + $query ->where('identifier', 'LIKE', '%' . $search . '%') |
|
48 | + ->orWhere('parameters', 'LIKE', '%' . $search . '%') |
|
49 | + ->orWhere('group', 'LIKE', '%' . $search . '%') |
|
50 | + ->orWhere('page_name', 'LIKE', '%' . $search . '%') |
|
51 | + ->orWhere('description', 'LIKE', '%' . $search . '%'); |
|
52 | 52 | }); |
53 | 53 | } |
54 | 54 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param $state string 'enabled|disabled' |
169 | 169 | * @return \Illuminate\Http\RedirectResponse |
170 | 170 | */ |
171 | - public function changeLiveMode ($state) |
|
171 | + public function changeLiveMode($state) |
|
172 | 172 | { |
173 | 173 | if ($state == 'enable') { |
174 | 174 | session(['translation_live_mode' => true]); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return $this->translations[$group][$identifier]; |
47 | 47 | } |
48 | 48 | else { |
49 | - throw new TranslationNotInCacheException("The translation identifier '".$identifier."' could not be found in Cache"); |
|
49 | + throw new TranslationNotInCacheException("The translation identifier '" . $identifier . "' could not be found in Cache"); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function refreshCache($group = 'default') |
60 | 60 | { |
61 | - $locale_dir = TranslatorFacade::getConfigValue('cache_path').$this->locale; |
|
61 | + $locale_dir = TranslatorFacade::getConfigValue('cache_path') . $this->locale; |
|
62 | 62 | |
63 | 63 | try { |
64 | - $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
|
64 | + $trans_identifier = json_decode(file_get_contents($locale_dir . '/' . $group . '.json'), true); |
|
65 | 65 | } catch (\ErrorException $e) { |
66 | - throw new TranslationCacheNotFound("The Translation cache file '".$locale_dir.'/'.$group.'.json'."' could not be found!"); |
|
66 | + throw new TranslationCacheNotFound("The Translation cache file '" . $locale_dir . '/' . $group . '.json' . "' could not be found!"); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $this->translations[$group] = $trans_identifier; |