update switch language
This commit is contained in:
parent
50a063358e
commit
8bc8ccff44
20
app/Http/Controllers/LanguageController.php
Normal file
20
app/Http/Controllers/LanguageController.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LanguageController extends Controller
|
||||
{
|
||||
public function switchLanguage(Request $request)
|
||||
{
|
||||
$locale = $request->input('locale');
|
||||
|
||||
if (!in_array($locale, ['en', 'pt'])) {
|
||||
abort(400);
|
||||
}
|
||||
|
||||
session(['locale' => $locale]);
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
@ -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' => [
|
||||
|
|
|
|||
25
app/Http/Middleware/Language.php
Normal file
25
app/Http/Middleware/Language.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class Language
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
// return $next($request);
|
||||
if (session('locale')) {
|
||||
app()->setLocale(session('locale'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -83,9 +83,7 @@
|
|||
|
|
||||
*/
|
||||
|
||||
// 'locale' => 'en',
|
||||
'locale' => 'pt',
|
||||
|
||||
'locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
140
resources/lang/en/messages.php
Normal file
140
resources/lang/en/messages.php
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
|
||||
return [
|
||||
|
||||
// Tudo relacionado ao dashboard, tanto a pagina como o navbarMenu
|
||||
'dashboard' => [
|
||||
//navbarMenu
|
||||
'dashboard' => 'Dashboard',
|
||||
|
||||
'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.'
|
||||
],
|
||||
],
|
||||
|
||||
//alterar na view Portfolio
|
||||
'portfolio' => [
|
||||
'top_view_part' => [
|
||||
'management_assets' => 'Management assets',
|
||||
'portfolio' => 'portfolio',
|
||||
'managing_assets' => 'Managing Assets',
|
||||
],
|
||||
'change_buttons' => [
|
||||
'create_assets' => 'Create assets',
|
||||
'asset_table' => 'Asset table',
|
||||
],
|
||||
'asset_table' => [
|
||||
''=> '',
|
||||
],
|
||||
'users_table' => [
|
||||
'id' => 'ID',
|
||||
'name' => 'Name',
|
||||
'email' => 'Email',
|
||||
'user_type' => 'User type',
|
||||
'actions' => [
|
||||
'actions' => 'Actions',
|
||||
'details' => 'Details',
|
||||
'edit'=> 'Edit',
|
||||
'delete' => 'Delete'
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'users_listUsers' => [
|
||||
//Navbar
|
||||
'users' => 'Users',
|
||||
'companies' => 'Companies',
|
||||
'create_users' => 'Create users',
|
||||
|
||||
'top_view_part' => [
|
||||
'companies' => 'Companies',
|
||||
'administration' => 'Administration',
|
||||
'users_table' => 'Users table',
|
||||
'companies_table' => 'Companies Table',
|
||||
],
|
||||
],
|
||||
|
||||
// View : Create Users
|
||||
'pendingUsers' => [
|
||||
'create_users' => 'Create Users',
|
||||
'administration' => 'Administration',
|
||||
'submit_form' => 'Submit Form',
|
||||
'pending_users' => 'Pending Users',
|
||||
'submit' => 'Submit',
|
||||
'table_pending_user' => [
|
||||
'name' => 'Name',
|
||||
'email' => 'Email',
|
||||
'verify' => 'Verify'
|
||||
],
|
||||
],
|
||||
|
||||
// View : createProject
|
||||
'createProject' => [
|
||||
//NavbarMenu
|
||||
"create_project"=> "Create a project",
|
||||
|
||||
'project_work_details' => 'Project Work Details',
|
||||
'project_identification' => 'Project identification',
|
||||
'ispt_project_number' => 'ISPT Project Number',
|
||||
'ispt_project_manager' => 'ISPT Project Manager',
|
||||
'compan_project_manager' => 'Company Project Manager',
|
||||
//Selecionar uma empresa.
|
||||
'select_company' => [
|
||||
'contracting_company' => 'Contracting Company',
|
||||
'select_company' => 'Select a contracting Company',
|
||||
],
|
||||
//Selecionar ou criar uma instalacao
|
||||
'select_plant' => [
|
||||
'plant' => 'Select Plant',
|
||||
'create_new_plant' => 'Create a new plant',
|
||||
'new_plant' => 'New plant',
|
||||
'plant_address' => 'Plant address',
|
||||
'select_plant' => 'Select Plant',
|
||||
],
|
||||
'company_project_number' => 'Company Project Number',
|
||||
'project_start_date' => 'Project Start Date',
|
||||
],
|
||||
|
||||
|
||||
'profile' => [
|
||||
'show_profile' => [
|
||||
'profile' => 'Profile',
|
||||
'full_name' => 'Full Name',
|
||||
'nif' => 'Nif',
|
||||
'email_address' => 'Email address',
|
||||
'user_type' => 'User type',
|
||||
'mobile_phone' => 'Mobile phone',
|
||||
'account_creation_date' => 'account_creation_date'
|
||||
],
|
||||
'edit_profile' => [
|
||||
'edit_profile'=> 'Edit profile',
|
||||
'update_your_logo' => 'Update your logo',
|
||||
'image' => 'Image',
|
||||
'full_name'=> 'Full name',
|
||||
'nif' => 'Nif',
|
||||
'email_address' => 'Email address',
|
||||
'mobile_phone' => 'mobile_phone',
|
||||
],
|
||||
],
|
||||
|
||||
//Botoes gerais ISPT4.0
|
||||
'buttons' => [
|
||||
'save' => 'save',
|
||||
],
|
||||
|
||||
'welcome' => 'Welcome to our application!',
|
||||
];
|
||||
0
resources/lang/en/validation.php
Normal file
0
resources/lang/en/validation.php
Normal file
136
resources/lang/pt/messages.php
Normal file
136
resources/lang/pt/messages.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'dashboard' => [
|
||||
//navbarMenu
|
||||
'dashboard' => 'Dashboard',
|
||||
|
||||
'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.'
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'portfolio' => [
|
||||
'top_view_part' => [
|
||||
'management_assets' => 'Gestão de ativos',
|
||||
'portfolio' => 'Portefólio',
|
||||
'managing_assets' => 'Gerir ativos',
|
||||
],
|
||||
'change_buttons' => [
|
||||
'create_assets' => 'Criar ativos',
|
||||
'asset_table' => 'Tabela de ativos',
|
||||
],
|
||||
'users_table' => [
|
||||
'id' => 'ID',
|
||||
'name' => 'Nome',
|
||||
'email' => 'Email',
|
||||
'user_type' => 'Tipo de Utilizador',
|
||||
'actions' => [
|
||||
'actions' => 'Ações',
|
||||
'details' => 'Detalhes',
|
||||
'edit' => 'Editar',
|
||||
'delete' => 'Excluir'
|
||||
],
|
||||
|
||||
],
|
||||
],
|
||||
|
||||
'users_listUsers' => [
|
||||
//Navbar
|
||||
'users' => 'Utilizadores',
|
||||
'companies' => 'Clientes',
|
||||
'create_users' => 'Criar Utilizadores',
|
||||
|
||||
'top_view_part' => [
|
||||
'companies' => 'Empresas',
|
||||
'administration' => 'Administração',
|
||||
'users_table' => 'Tabela Utilizadores',
|
||||
'companies_table' => 'Tabela Empresas',
|
||||
],
|
||||
],
|
||||
|
||||
// View : Create Users
|
||||
'pendingUsers' => [
|
||||
'create_users' => 'Criar Utilizadores',
|
||||
'administration' => 'Administração',
|
||||
'submit_form' => 'Enviar Formulário',
|
||||
'pending_users' => 'Utilizadores Pendentes',
|
||||
'submit' => 'Enviar',
|
||||
'table_pending_user' => [
|
||||
'name' => 'Nome',
|
||||
'email' => 'Email',
|
||||
'verify' => 'Verificar'
|
||||
],
|
||||
],
|
||||
|
||||
// View : createProject
|
||||
'createProject' => [
|
||||
//NavbarMenu
|
||||
"create_project" => "Criar obra",
|
||||
|
||||
'project_work_details' => 'Detalhes Técnicos do Projeto',
|
||||
'project_identification' => 'Identificação do projecto',
|
||||
'ispt_project_number' => 'Número do Projeto ISPT',
|
||||
'ispt_project_manager' => 'Gestor de Projeto ISPT',
|
||||
'compan_project_manager' => 'Gestor de Projeto da Empresa',
|
||||
//Selecionar uma empresa.
|
||||
'select_company' => [
|
||||
'contracting_company' => 'Empresa Contratante',
|
||||
'select_company' => 'Selecionar uma Empresa',
|
||||
],
|
||||
//Selecionar ou criar uma instalacao
|
||||
'select_plant' => [
|
||||
'plant' => 'Instalação',
|
||||
'create_new_plant' => 'Criar uma nova Instalacao',
|
||||
'new_plant' => 'Nova Instalação',
|
||||
'plant_address' => 'Morada Instalação',
|
||||
'select_plant' => 'Selecione uma Instalação',
|
||||
],
|
||||
'company_project_number' => 'Número do Projeto da Empresa',
|
||||
'project_start_date' => 'Data de Início do Projeto',
|
||||
],
|
||||
|
||||
//view: usersProfiles
|
||||
'profile' => [
|
||||
'show_profile' => [
|
||||
'profile' => 'Perfil',
|
||||
'full_name' => 'Nome e Apelido',
|
||||
'nif' => 'Nif',
|
||||
'email_address' => 'Email',
|
||||
'user_type' => 'Tipo de utilizador',
|
||||
'mobile_phone' => 'Telemóvel',
|
||||
'account_creation_date' => 'Conta Criada em'
|
||||
],
|
||||
'edit_profile' => [
|
||||
'update_your_logo' => 'Actualizar o seu logótipo',
|
||||
'image' => 'Imagem',
|
||||
'full_name'=> 'Nome e Apelido',
|
||||
'nif' => 'Nif',
|
||||
'email_address' => 'Email',
|
||||
'mobile_phone' => 'Telemóvel',
|
||||
],
|
||||
],
|
||||
|
||||
'buttons' => [
|
||||
'save' => 'Guardar',
|
||||
],
|
||||
|
||||
'welcome' => 'Bem-vindo à nossa aplicação!',
|
||||
// outras traduções
|
||||
];
|
||||
|
|
@ -210,8 +210,18 @@ class="fas fa-bars"></i></a>
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Right navbar links -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<form id="language-form" action="{{ route('language.switch') }}" method="post">
|
||||
@csrf
|
||||
<select name="locale" onchange="this.form.submit()">
|
||||
<option value="en" {{ app()->getLocale() == 'en' ? 'selected' : '' }}>English</option>
|
||||
<option value="pt" {{ app()->getLocale() == 'pt' ? 'selected' : '' }}>Português</option>
|
||||
</select>
|
||||
</form>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="fullscreen" href="#" role="button">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
use App\Http\Controllers\PreparedProjectController;
|
||||
use App\Http\Controllers\ExecutionProjectController;
|
||||
use App\Http\Controllers\WorkstationsJobsController;
|
||||
use App\Http\Controllers\LanguageController;
|
||||
|
||||
Route::post('language/switch', [LanguageController::class, 'switchLanguage'])->name('language.switch');
|
||||
|
||||
// Esta rota so pode aceder quem tiver o link atravez do email
|
||||
Route::get('formulario', function () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user