@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $matches = $this->getMatchesFromAcceptedLanguages(); |
| 65 | 65 | |
| 66 | 66 | foreach ($matches as $key => $q) { |
| 67 | - if (! empty($this->supportedLanguages[$key])) { |
|
| 67 | + if (!empty($this->supportedLanguages[$key])) { |
|
| 68 | 68 | return $key; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | return key($this->supportedLanguages); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ($this->use_intl && ! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 90 | + if ($this->use_intl && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 91 | 91 | $http_accept_language = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); |
| 92 | 92 | |
| 93 | - if (! empty($this->supportedLanguages[$http_accept_language])) { |
|
| 93 | + if (!empty($this->supportedLanguages[$http_accept_language])) { |
|
| 94 | 94 | return $http_accept_language; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $remote_host = explode('.', $this->request->server('REMOTE_HOST')); |
| 100 | 100 | $lang = strtolower(end($remote_host)); |
| 101 | 101 | |
| 102 | - if (! empty($this->supportedLanguages[$lang])) { |
|
| 102 | + if (!empty($this->supportedLanguages[$lang])) { |
|
| 103 | 103 | return $lang; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | //less than it's parent. |
| 144 | 144 | $l_ops = explode('-', $l); |
| 145 | 145 | array_pop($l_ops); |
| 146 | - while (! empty($l_ops)) { |
|
| 146 | + while (!empty($l_ops)) { |
|
| 147 | 147 | //The new generic option needs to be slightly less important than it's base |
| 148 | 148 | $q -= 0.001; |
| 149 | 149 | $op = implode('-', $l_ops); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; |
| 26 | 26 | $pass = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : ''; |
| 27 | 27 | $url .= $user.(($user || $pass) ? "$pass@" : ''); |
| 28 | - if (! empty($url)) { |
|
| 28 | + if (!empty($url)) { |
|
| 29 | 29 | $url .= isset($parsed_url['path']) ? '/'.ltrim($parsed_url['path'], '/') : ''; |
| 30 | 30 | } elseif (empty($url)) { |
| 31 | 31 | $url .= isset($parsed_url['path']) ? $parsed_url['path'] : ''; |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | use Pmochine\LaravelTongue\Tongue; |
| 4 | 4 | use Pmochine\LaravelTongue\Dialect; |
| 5 | 5 | |
| 6 | -if (! function_exists('tongue')) { |
|
| 6 | +if (!function_exists('tongue')) { |
|
| 7 | 7 | function tongue() |
| 8 | 8 | { |
| 9 | 9 | return app()->make(Tongue::class); |
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | -if (! function_exists('dialect')) { |
|
| 12 | +if (!function_exists('dialect')) { |
|
| 13 | 13 | function dialect() |
| 14 | 14 | { |
| 15 | 15 | return app()->make(Dialect::class); |
@@ -20,11 +20,11 @@ |
||
| 20 | 20 | 'localization' |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - $this->app->singleton('tongue', function ($app) { |
|
| 23 | + $this->app->singleton('tongue', function($app) { |
|
| 24 | 24 | return new Tongue($app); |
| 25 | 25 | }); |
| 26 | 26 | |
| 27 | - $this->app->singleton('dialect', function ($app) { |
|
| 27 | + $this->app->singleton('dialect', function($app) { |
|
| 28 | 28 | return new Dialect($app); |
| 29 | 29 | }); |
| 30 | 30 | } |
@@ -74,24 +74,24 @@ discard block |
||
| 74 | 74 | //'cy' => ['name' => 'Welsh', 'script' => 'Latn', 'native' => 'Cymraeg', 'regional' => 'cy_GB'], |
| 75 | 75 | //'da' => ['name' => 'Danish', 'script' => 'Latn', 'native' => 'dansk', 'regional' => 'da_DK'], |
| 76 | 76 | //'se' => ['name' => 'Northern Sami', 'script' => 'Latn', 'native' => 'davvisámegiella', 'regional' => 'se_NO'], |
| 77 | - 'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE'], |
|
| 77 | + 'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE'], |
|
| 78 | 78 | //'luo' => ['name' => 'Luo', 'script' => 'Latn', 'native' => 'Dholuo', 'regional' => ''], |
| 79 | 79 | //'nv' => ['name' => 'Navajo', 'script' => 'Latn', 'native' => 'Diné bizaad', 'regional' => ''], |
| 80 | 80 | //'dua' => ['name' => 'Duala', 'script' => 'Latn', 'native' => 'duálá', 'regional' => ''], |
| 81 | 81 | //'et' => ['name' => 'Estonian', 'script' => 'Latn', 'native' => 'eesti', 'regional' => 'et_EE'], |
| 82 | 82 | //'na' => ['name' => 'Nauru', 'script' => 'Latn', 'native' => 'Ekakairũ Naoero', 'regional' => ''], |
| 83 | 83 | //'guz' => ['name' => 'Ekegusii', 'script' => 'Latn', 'native' => 'Ekegusii', 'regional' => ''], |
| 84 | - 'en' => ['name' => 'English', 'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'], |
|
| 84 | + 'en' => ['name' => 'English', 'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'], |
|
| 85 | 85 | //'en-AU' => ['name' => 'Australian English', 'script' => 'Latn', 'native' => 'Australian English', 'regional' => 'en_AU'], |
| 86 | 86 | //'en-GB' => ['name' => 'British English', 'script' => 'Latn', 'native' => 'British English', 'regional' => 'en_GB'], |
| 87 | 87 | //'en-US' => ['name' => 'U.S. English', 'script' => 'Latn', 'native' => 'U.S. English', 'regional' => 'en_US'], |
| 88 | - 'es' => ['name' => 'Spanish', 'script' => 'Latn', 'native' => 'español', 'regional' => 'es_ES'], |
|
| 88 | + 'es' => ['name' => 'Spanish', 'script' => 'Latn', 'native' => 'español', 'regional' => 'es_ES'], |
|
| 89 | 89 | //'eo' => ['name' => 'Esperanto', 'script' => 'Latn', 'native' => 'esperanto', 'regional' => ''], |
| 90 | 90 | //'eu' => ['name' => 'Basque', 'script' => 'Latn', 'native' => 'euskara', 'regional' => 'eu_ES'], |
| 91 | 91 | //'ewo' => ['name' => 'Ewondo', 'script' => 'Latn', 'native' => 'ewondo', 'regional' => ''], |
| 92 | 92 | //'ee' => ['name' => 'Ewe', 'script' => 'Latn', 'native' => 'eʋegbe', 'regional' => ''], |
| 93 | 93 | //'fil' => ['name' => 'Filipino', 'script' => 'Latn', 'native' => 'Filipino', 'regional' => 'fil_PH'], |
| 94 | - 'fr' => ['name' => 'French', 'script' => 'Latn', 'native' => 'français', 'regional' => 'fr_FR'], |
|
| 94 | + 'fr' => ['name' => 'French', 'script' => 'Latn', 'native' => 'français', 'regional' => 'fr_FR'], |
|
| 95 | 95 | //'fr-CA' => ['name' => 'Canadian French', 'script' => 'Latn', 'native' => 'français canadien', 'regional' => 'fr_CA'], |
| 96 | 96 | //'fy' => ['name' => 'Western Frisian', 'script' => 'Latn', 'native' => 'frysk', 'regional' => 'fy_DE'], |
| 97 | 97 | //'fur' => ['name' => 'Friulian', 'script' => 'Latn', 'native' => 'furlan', 'regional' => 'fur_IT'], |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | //'lg' => ['name' => 'Ganda', 'script' => 'Latn', 'native' => 'Luganda', 'regional' => 'lg_UG'], |
| 163 | 163 | //'luy' => ['name' => 'Oluluyia', 'script' => 'Latn', 'native' => 'Luluhia', 'regional' => ''], |
| 164 | 164 | //'lb' => ['name' => 'Luxembourgish', 'script' => 'Latn', 'native' => 'Lëtzebuergesch', 'regional' => 'lb_LU'], |
| 165 | - 'hu' => ['name' => 'Hungarian', 'script' => 'Latn', 'native' => 'magyar', 'regional' => 'hu_HU'], |
|
| 165 | + 'hu' => ['name' => 'Hungarian', 'script' => 'Latn', 'native' => 'magyar', 'regional' => 'hu_HU'], |
|
| 166 | 166 | //'mgh' => ['name' => 'Makhuwa-Meetto', 'script' => 'Latn', 'native' => 'Makua', 'regional' => ''], |
| 167 | 167 | //'mg' => ['name' => 'Malagasy', 'script' => 'Latn', 'native' => 'Malagasy', 'regional' => 'mg_MG'], |
| 168 | 168 | //'mt' => ['name' => 'Maltese', 'script' => 'Latn', 'native' => 'Malti', 'regional' => 'mt_MT'], |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | public function translate($routeName, $routeAttributes = null, $locale = null) |
| 124 | 124 | { |
| 125 | 125 | // If no locale is given, we use the current locale |
| 126 | - if (! $locale) { |
|
| 126 | + if (!$locale) { |
|
| 127 | 127 | $locale = tongue()->current(); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $routePath = Accent::findRoutePathByName($routeName); |
| 165 | 165 | |
| 166 | - if (! isset($this->translatedRoutes[$routeName])) { |
|
| 166 | + if (!isset($this->translatedRoutes[$routeName])) { |
|
| 167 | 167 | $this->translatedRoutes[$routeName] = $routePath; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function handle($request, Closure $next) |
| 21 | 21 | { |
| 22 | - if (tongue()->twister() && ! Config::preventRedirect()) { |
|
| 22 | + if (tongue()->twister() && !Config::preventRedirect()) { |
|
| 23 | 23 | return dialect()->redirect(dialect()->redirectURL()); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $locale = $this->app->getLocale(); |
| 49 | 49 | |
| 50 | - if (! $key) { |
|
| 50 | + if (!$key) { |
|
| 51 | 51 | return $locale; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | //fallback language is the same as the current language |
| 96 | 96 | if (Config::beautify() && $this->current() === Config::fallbackLocale()) { |
| 97 | 97 | //didn't found locale means browser is set to exmaple.com |
| 98 | - if (! $locale) { |
|
| 98 | + if (!$locale) { |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | //browser is set to en.example.com but should be forced back to example.com |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function speaks(string $locale) |
| 119 | 119 | { |
| 120 | - if (! $this->isSpeaking($locale)) { |
|
| 120 | + if (!$this->isSpeaking($locale)) { |
|
| 121 | 121 | return abort(404); //oder error? |
| 122 | 122 | } |
| 123 | 123 | |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $locales = Config::supportedLocales(); |
| 161 | 161 | |
| 162 | - if (empty($locales) || ! is_array($locales)) { |
|
| 162 | + if (empty($locales) || !is_array($locales)) { |
|
| 163 | 163 | throw new SupportedLocalesNotDefined(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if (! $key) { |
|
| 166 | + if (!$key) { |
|
| 167 | 167 | return collect($locales); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | return $this->BCP47($locale, $locales); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if (! Arr::has($locales, "{$locale}.{$key}")) { |
|
| 174 | + if (!Arr::has($locales, "{$locale}.{$key}")) { |
|
| 175 | 175 | throw new SupportedLocalesNotDefined(); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | $bcp47 = data_get($locales, "{$locale}.regional"); |
| 213 | 213 | |
| 214 | - if (! $bcp47) { |
|
| 214 | + if (!$bcp47) { |
|
| 215 | 215 | return $locale; |
| 216 | 216 | } //locale is the "minimum" of BCP 47 |
| 217 | 217 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $locale = self::fromUrl(); |
| 22 | 22 | |
| 23 | - if (! $locale || ! tongue()->isSpeaking($locale)) { |
|
| 24 | - if (! Config::beautify()) { |
|
| 23 | + if (!$locale || !tongue()->isSpeaking($locale)) { |
|
| 24 | + if (!Config::beautify()) { |
|
| 25 | 25 | return Config::fallbackLocale(); //redirects see test it_ignoes_cookies_and_redirects.... |
| 26 | 26 | } |
| 27 | 27 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected static function languageIsSet() |
| 88 | 88 | { |
| 89 | - return ! app()->runningInConsole() || Arr::has(request()->server(), 'HTTP_ACCEPT_LANGUAGE'); |
|
| 89 | + return !app()->runningInConsole() || Arr::has(request()->server(), 'HTTP_ACCEPT_LANGUAGE'); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | return cookie()->queue(cookie()->forever(self::COOKIE, $locale)); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if (! request()->hasCookie(self::COOKIE)) { |
|
| 106 | + if (!request()->hasCookie(self::COOKIE)) { |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |