diff --git a/app/Http/Controllers/LanguageController.php b/app/Http/Controllers/LanguageController.php new file mode 100644 index 00000000..acae3ed8 --- /dev/null +++ b/app/Http/Controllers/LanguageController.php @@ -0,0 +1,21 @@ +input('locale'); + + if (!in_array($locale, ['en', 'pt'])) { + abort(400); + } + + session(['locale' => $locale]); + return redirect()->back(); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index a237b67b..a3524b19 100755 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,6 +36,7 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, + \App\Http\Middleware\Language::class, ], 'api' => [ diff --git a/app/Http/Middleware/Language.php b/app/Http/Middleware/Language.php new file mode 100644 index 00000000..4906e51a --- /dev/null +++ b/app/Http/Middleware/Language.php @@ -0,0 +1,25 @@ +setLocale(session('locale')); + } + + return $next($request); + } +} diff --git a/config/app.php b/config/app.php index 1bbd47cc..0f3e510b 100755 --- a/config/app.php +++ b/config/app.php @@ -83,9 +83,7 @@ | */ - // 'locale' => 'en', - 'locale' => 'pt', - + 'locale' => 'en', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php new file mode 100644 index 00000000..9f1f0cef --- /dev/null +++ b/resources/lang/en/messages.php @@ -0,0 +1,28 @@ + [ + 'planning' => [ + 'description' => 'In planning', + 'text' => 'In planning for 2023' + ], + 'prepared' => [ + 'description' => 'Prepared', + 'text' => 'Waiting for the work to start.' + ], + 'on_going' => [ + 'description' => 'On going', + 'text' => 'Work in progress.' + ], + 'finished' => [ + 'description' => 'Finished.', + 'text' => 'Last projects 2023.' + ], + + ], + + 'welcome' => 'Welcome to our application!', +]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php new file mode 100644 index 00000000..e69de29b diff --git a/resources/lang/pt/messages.php b/resources/lang/pt/messages.php new file mode 100644 index 00000000..c3be677a --- /dev/null +++ b/resources/lang/pt/messages.php @@ -0,0 +1,29 @@ + [ + 'planning' => [ + 'description' => 'Em planeamento', + 'text' => 'Em planeamento de 2023' + ], + 'prepared' => [ + 'description' => 'Preparadas', + 'text' => 'Aguarda o início da obra.' + ], + 'on_going' => [ + 'description' => 'Em execução', + 'text' => 'Obra em curso.' + ], + 'finished' => [ + 'description' => 'Concluídas', + 'text' => 'Últimas obras de 2023.' + ], + + ], + + + 'welcome' => 'Bem-vindo à nossa aplicação!', + // outras traduções +]; \ No newline at end of file diff --git a/resources/views/Admin/index.blade.php b/resources/views/Admin/index.blade.php index aa5eab8b..126859b0 100755 --- a/resources/views/Admin/index.blade.php +++ b/resources/views/Admin/index.blade.php @@ -32,11 +32,11 @@