@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | // Register blade directives |
| 51 | - Blade::directive('t', function ($expression) { |
|
| 51 | + Blade::directive('t', function($expression) { |
|
| 52 | 52 | return "<?php echo e(t({$expression})); ?>"; |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | - $this->app['events']->listen(RouteMatched::class, function () { |
|
| 55 | + $this->app['events']->listen(RouteMatched::class, function() { |
|
| 56 | 56 | $scope = $this->app['config']->get('app.scope'); |
| 57 | 57 | if ($scope && $scope != 'global') { |
| 58 | 58 | $this->app['multilang']->setScope($scope); |
| 59 | 59 | } |
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | - $this->app['events']->listen(LocaleUpdated::class, function ($event) { |
|
| 62 | + $this->app['events']->listen(LocaleUpdated::class, function($event) { |
|
| 63 | 63 | $this->app['multilang']->setLocale($event->locale); |
| 64 | 64 | }); |
| 65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $configPath = __DIR__ . '/../config/config.php'; |
| 72 | 72 | $this->mergeConfigFrom($configPath, 'debugbar'); |
| 73 | 73 | |
| 74 | - $this->app->singleton('multilang', function (Application $app) { |
|
| 74 | + $this->app->singleton('multilang', function(Application $app) { |
|
| 75 | 75 | $environment = $app->environment(); |
| 76 | 76 | $config = $app['config']->get('multilang'); |
| 77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | if ($multilang->autoSaveIsAllowed()) { |
| 86 | - $app->terminating(function () use ($multilang) { |
|
| 86 | + $app->terminating(function() use ($multilang) { |
|
| 87 | 87 | $scope = $this->app['config']->get('app.scope'); |
| 88 | 88 | if ($scope && $scope != 'global') { |
| 89 | 89 | $multilang->setScope($scope); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ] |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - Request::macro('locale', function () { |
|
| 110 | + Request::macro('locale', function() { |
|
| 111 | 111 | return app('multilang')->getLocale(); |
| 112 | 112 | }); |
| 113 | 113 | } |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function setLocale(string $lang, ?array $texts = null): void |
| 168 | 168 | { |
| 169 | - if (! $lang) { |
|
| 169 | + if (!$lang) { |
|
| 170 | 170 | throw new InvalidArgumentException('Locale is empty'); |
| 171 | 171 | } |
| 172 | 172 | $this->lang = $lang; |
| 173 | 173 | |
| 174 | - if (! is_array($texts)) { |
|
| 174 | + if (!is_array($texts)) { |
|
| 175 | 175 | $texts = $this->loadTexts($this->getLocale(), $this->scope); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | throw new InvalidArgumentException('String key not provided'); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if (! $this->lang) { |
|
| 220 | + if (!$this->lang) { |
|
| 221 | 221 | return $key; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if (! isset($this->texts[$key])) { |
|
| 224 | + if (!isset($this->texts[$key])) { |
|
| 225 | 225 | $this->queueToSave($key); |
| 226 | 226 | |
| 227 | 227 | return $this->replaceMarkers($key, $replace); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | protected function sortReplacements(array $replace): Collection |
| 280 | 280 | { |
| 281 | - return (new Collection($replace))->sortBy(function ($value, $key) { |
|
| 281 | + return (new Collection($replace))->sortBy(function($value, $key) { |
|
| 282 | 282 | return mb_strlen($key) * -1; |
| 283 | 283 | }); |
| 284 | 284 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | if (strlen($locale) == 2) { |
| 302 | 302 | $locales = $this->config->get('locales', []); |
| 303 | 303 | |
| 304 | - if (! isset($locales[$locale])) { |
|
| 304 | + if (!isset($locales[$locale])) { |
|
| 305 | 305 | $segments = $request->segments(); |
| 306 | 306 | $segments[0] = $fallback_locale; |
| 307 | 307 | $url = implode('/', $segments); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function getCacheName(string $lang, ?string $scope = null): string |
| 59 | 59 | { |
| 60 | 60 | $key = $this->config->get('db.texts_table', 'texts') . '_' . $lang; |
| 61 | - if (! is_null($scope)) { |
|
| 61 | + if (!is_null($scope)) { |
|
| 62 | 62 | $key .= '_' . $scope; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | $query = $this->getDb()->table($this->getTableName()) |
| 78 | 78 | ->where('lang', $lang); |
| 79 | 79 | |
| 80 | - if (! is_null($scope) && $scope !== 'global') { |
|
| 81 | - $query = $query->whereNested(function ($query) use ($scope) { |
|
| 80 | + if (!is_null($scope) && $scope !== 'global') { |
|
| 81 | + $query = $query->whereNested(function($query) use ($scope) { |
|
| 82 | 82 | $query->where('scope', 'global'); |
| 83 | 83 | $query->orWhere('scope', $scope); |
| 84 | 84 | }); |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $query = $this->getDb()->table($this->getTableName()); |
| 109 | 109 | |
| 110 | - if (! is_null($lang)) { |
|
| 110 | + if (!is_null($lang)) { |
|
| 111 | 111 | $query = $query->where('lang', $lang); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if (! is_null($scope)) { |
|
| 115 | - $query = $query->whereNested(function ($query) use ($scope) { |
|
| 114 | + if (!is_null($scope)) { |
|
| 115 | + $query = $query->whereNested(function($query) use ($scope) { |
|
| 116 | 116 | $query->where('scope', 'global'); |
| 117 | 117 | $query->orWhere('scope', $scope); |
| 118 | 118 | }); |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | $this->db = $this->getDatabase(); |
| 83 | 83 | |
| 84 | 84 | $lang = $this->option('lang'); |
| 85 | - if (! empty($lang)) { |
|
| 85 | + if (!empty($lang)) { |
|
| 86 | 86 | $this->langs = explode(',', $lang); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $scopes = $this->scopes; |
| 90 | 90 | $scope = $this->option('scope'); |
| 91 | - if (! empty($scope)) { |
|
| 91 | + if (!empty($scope)) { |
|
| 92 | 92 | $scopes = explode(',', $scope); |
| 93 | 93 | foreach ($scopes as $scope) { |
| 94 | - if (! in_array($scope, $this->scopes)) { |
|
| 94 | + if (!in_array($scope, $this->scopes)) { |
|
| 95 | 95 | throw new InvalidArgumentException('Scope "' . $scope . '" is not found! Available scopes is ' . implode(', ', $this->scopes)); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $path = $this->option('path', 'storage/multilang'); |
| 101 | 101 | $this->path = base_path($path); |
| 102 | - if (! is_dir($this->path)) { |
|
| 102 | + if (!is_dir($this->path)) { |
|
| 103 | 103 | throw new InvalidArgumentException('Folder "' . $this->path . '" is not accessible!'); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | protected function import(string $scope = 'global', bool $force = false, bool $clear = false): void |
| 114 | 114 | { |
| 115 | 115 | $path = $this->path . '/' . $scope . '.yml'; |
| 116 | - if (! is_readable($path)) { |
|
| 116 | + if (!is_readable($path)) { |
|
| 117 | 117 | $this->warn('File "' . $path . '" is not readable!'); |
| 118 | 118 | |
| 119 | 119 | return; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $key = $text['key']; |
| 141 | 141 | |
| 142 | 142 | foreach ($text['texts'] as $lang => $value) { |
| 143 | - if (! empty($this->langs) && ! in_array($lang, $this->langs)) { |
|
| 143 | + if (!empty($this->langs) && !in_array($lang, $this->langs)) { |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |