diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 341225ba..5995b48a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -4,7 +4,6 @@ namespace App\Exceptions; use Exception; use App\Exceptions\PrettyPageException; -use App\Http\Middleware\Internationalization; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Validation\ValidationException; use Symfony\Component\HttpKernel\Exception\HttpException; @@ -49,9 +48,6 @@ class Handler extends ExceptionHandler */ public function render($request, Exception $e) { - // call i18n middleware manually since http exceptions won't be sent through it - (new Internationalization)->handle($request, function(){}); - if ($e instanceof ModelNotFoundException) { $e = new NotFoundHttpException($e->getMessage(), $e); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9b8f7843..033c157e 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -29,13 +29,10 @@ class Kernel extends HttpKernel \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, - \App\Http\Middleware\Internationalization::class, \App\Http\Middleware\SaveOptionRepository::class, ], - 'static' => [ - \App\Http\Middleware\Internationalization::class, - ], + 'static' => [], ]; /** diff --git a/app/Http/Middleware/Internationalization.php b/app/Http/Middleware/Internationalization.php deleted file mode 100644 index c0322719..00000000 --- a/app/Http/Middleware/Internationalization.php +++ /dev/null @@ -1,28 +0,0 @@ - Cookie::get('locale')]); - } - - if (Session::has('locale')) { - // Set app locale dynamically - App::setLocale(session('locale')); - } else { - App::setLocale($request->getPreferredLanguage()); - } - - return $next($request); - } -} diff --git a/app/Providers/BootServiceProvider.php b/app/Providers/BootServiceProvider.php index 317510f1..cca3d964 100644 --- a/app/Providers/BootServiceProvider.php +++ b/app/Providers/BootServiceProvider.php @@ -23,6 +23,9 @@ class BootServiceProvider extends ServiceProvider { View::addExtension('tpl', 'blade'); + // set current locale + $this->i18n($request); + // check dotenv if (!file_exists(base_path('.env'))) { throw new PrettyPageException(trans('setup.file.no-dot-env'), -1); @@ -67,6 +70,15 @@ class BootServiceProvider extends ServiceProvider return true; } + protected function i18n($request) + { + $locale = $request->input('lang') ?: ($request->cookie('locale') ?: $request->getPreferredLanguage()); + + app()->setLocale($locale); + session()->set('locale', $locale); + cookie()->queue('locale', $locale); + } + /** * Register any application services. * diff --git a/resources/assets/src/sass/install.scss b/resources/assets/src/sass/install.scss index 2984d5ac..deea1ae7 100644 --- a/resources/assets/src/sass/install.scss +++ b/resources/assets/src/sass/install.scss @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-28 13:15:18 * @Last Modified by: printempw - * @Last Modified time: 2016-12-31 17:08:19 + * @Last Modified time: 2017-01-08 14:59:42 */ @import "style.scss"; @@ -29,6 +29,7 @@ h1, h2 { color: #666; font-size: 24px; font-weight: 400; + padding: 0px 0px 7px; } p { diff --git a/resources/views/errors/403.tpl b/resources/views/errors/403.tpl index 8abdf4f2..eb83b47a 100644 --- a/resources/views/errors/403.tpl +++ b/resources/views/errors/403.tpl @@ -3,7 +3,9 @@ @section('title', '403 Forbidden') @section('content') -
{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-403')]) }}
@endsection diff --git a/resources/views/errors/404.tpl b/resources/views/errors/404.tpl index ebe7ebca..d9544524 100644 --- a/resources/views/errors/404.tpl +++ b/resources/views/errors/404.tpl @@ -3,8 +3,9 @@ @section('title', '404 Not Found') @section('content') - -{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-404')]) }}
@endsection diff --git a/resources/views/errors/503.tpl b/resources/views/errors/503.tpl index 349e3234..143c4c8d 100644 --- a/resources/views/errors/503.tpl +++ b/resources/views/errors/503.tpl @@ -3,7 +3,9 @@ @section('title', '503 Service Unavailable') @section('content') -{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-503')]) }}
@endsection diff --git a/resources/views/errors/brief.tpl b/resources/views/errors/brief.tpl index ec9c6fb6..a4c30721 100644 --- a/resources/views/errors/brief.tpl +++ b/resources/views/errors/brief.tpl @@ -3,7 +3,9 @@ @section('title', trans('errors.general.title')) @section('content') -{{ trans('errors.brief.message') }}
diff --git a/resources/views/errors/exception.tpl b/resources/views/errors/exception.tpl index 9805c6c2..dbdae620 100644 --- a/resources/views/errors/exception.tpl +++ b/resources/views/errors/exception.tpl @@ -3,7 +3,9 @@ @section('title', trans('errors.general.title')) @section('content') -{{ trans('errors.exception.message', ['msg' => $message]) }}
diff --git a/resources/views/errors/general.tpl b/resources/views/errors/general.tpl index 45349c51..eeb7cd24 100644 --- a/resources/views/errors/general.tpl +++ b/resources/views/errors/general.tpl @@ -6,6 +6,7 @@