From 61bd6bc5f9d90d1906952db5bbf0e3e68d3c5a20 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Fri, 8 Jan 2016 10:18:18 +0000 Subject: [PATCH 1/2] Fixing composer.json --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 7e84726..bade99c 100644 --- a/composer.json +++ b/composer.json @@ -2,24 +2,24 @@ "name": "arcanedev/localization", "description": "Localization Package for Laravel", "keywords": ["arcanedev", "laravel", "localization", "localisation", "i18n"], - "homepage": "https://github.com/ARCANEDEV/Workbench", + "homepage": "https://github.com/ARCANEDEV/Localization", "authors": [ { "name": "ARCANEDEV", "email": "arcanedev.maroc@gmail.com", - "homepage": "https://github.com/ARCANEDEV", + "homepage": "https://github.com/arcanedev-maroc", "role": "Developer" } ], "type": "library", "license": "MIT", "require": { - "php" : ">=5.5.9", - "arcanedev/support": "~3.6.0" + "php" : ">=5.5.9", + "arcanedev/support": "~3.6.0" }, "require-dev": { - "phpunit/phpcov": "~2.0", - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/phpcov": "~2.0", + "phpunit/phpunit": "~4.0|~5.0" }, "autoload": { "psr-4": { From 95e2f5613fafc0099f45c119babc25ab54425966 Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Fri, 8 Jan 2016 10:20:02 +0000 Subject: [PATCH 2/2] Fixing Session & Cookie middleware when the default locale is hidden [#8] --- src/Middleware/LocaleCookieRedirect.php | 13 ++++++++----- src/Middleware/LocaleSessionRedirect.php | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Middleware/LocaleCookieRedirect.php b/src/Middleware/LocaleCookieRedirect.php index 2fc8bf1..e52977e 100644 --- a/src/Middleware/LocaleCookieRedirect.php +++ b/src/Middleware/LocaleCookieRedirect.php @@ -28,15 +28,18 @@ class LocaleCookieRedirect extends Middleware */ public function handle(Request $request, Closure $next) { - $locale = $request->segment(1, null); + $segment = $request->segment(1, null); + $locale = $request->cookie('locale', null); - if (localization()->isLocaleSupported($locale)) { - cookie('locale', $locale); + if (localization()->isLocaleSupported($segment)) { + cookie('locale', $segment); return $next($request); } - - $locale = $request->cookie('locale', null); + elseif (localization()->isDefaultLocaleHiddenInUrl()) { + $locale = localization()->getDefaultLocale(); + cookie('locale', $locale); + } if (is_string($locale) && ! $this->isDefaultLocaleHidden($locale)) { session()->reflash(); diff --git a/src/Middleware/LocaleSessionRedirect.php b/src/Middleware/LocaleSessionRedirect.php index 3e8f617..ff4730d 100644 --- a/src/Middleware/LocaleSessionRedirect.php +++ b/src/Middleware/LocaleSessionRedirect.php @@ -28,15 +28,18 @@ class LocaleSessionRedirect extends Middleware */ public function handle(Request $request, Closure $next) { - $locale = $request->segment(1, null); + $segment = $request->segment(1, null); + $locale = session('locale', null); - if (localization()->isLocaleSupported($locale)) { - session()->put(compact('locale')); + if (localization()->isLocaleSupported($segment)) { + session()->put(['locale' => $segment]); return $next($request); } - - $locale = session('locale', null); + elseif (localization()->isDefaultLocaleHiddenInUrl()) { + $locale = localization()->getDefaultLocale(); + session()->put(compact('locale')); + } if (is_string($locale) && ! $this->isDefaultLocaleHidden($locale)) { session()->reflash();