diff --git a/app/Http/Controllers/LangController.php b/app/Http/Controllers/LangController.php new file mode 100644 index 0000000..d94db59 --- /dev/null +++ b/app/Http/Controllers/LangController.php @@ -0,0 +1,21 @@ +lang); + session()->put('locale', $request->lang); + return redirect()->back(); + } +} diff --git a/app/Http/Controllers/LocaleController.php b/app/Http/Controllers/LocaleController.php deleted file mode 100644 index 28ba8d9..0000000 --- a/app/Http/Controllers/LocaleController.php +++ /dev/null @@ -1,29 +0,0 @@ -put('locale', $locale); - - // Redirect back or to a specific route after setting locale - return Redirect::back(); - } -} diff --git a/app/Http/Middleware/LangManager.php b/app/Http/Middleware/LangManager.php new file mode 100644 index 0000000..ae57379 --- /dev/null +++ b/app/Http/Middleware/LangManager.php @@ -0,0 +1,25 @@ +has('locale')) { + App::setLocale(session()->get('locale')); + } + return $next($request); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index 0c986dc..5fac6eb 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,7 +11,9 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->web(append: [ + App\Http\Middleware\LangManager::class + ]); }) ->withExceptions(function (Exceptions $exceptions) { // @@ -19,5 +21,5 @@ return Application::configure(basePath: dirname(__DIR__)) $app->middleware([ // Other middleware, - \App\Http\Middleware\SetLocale::class, + \App\Http\Middleware\LangManager::class, ]); diff --git a/lang/en/message.php b/lang/en/message.php new file mode 100644 index 0000000..51de0aa --- /dev/null +++ b/lang/en/message.php @@ -0,0 +1,44 @@ + "Dashboard", +"Charts"=>"Charts", + +"User Management"=>"User Management", +"All Users"=> "All Users", +"Add Users"=> "Add Users", +"UI Elements"=> "UI Elements", +"Forms"=>"Forms", +"Tables"=> "Tables", +"EXAMPLES"=>"EXAMPLES", +"Calendar"=> "Calendar", +"Gallery"=> "Gallery", +"Kanban Board"=> "Kanban Board", +"Mailbox"=> "Mailbox", +"Pages"=> "Pages", +"Extras"=> "Extras", +"Search"=>"Search", +"MISCELLANEOUS"=> "MISCELLANEOUS", +"Documentation"=>"Documentation", +"LABELS"=>"LABELS", +"Important"=>"Important", +"Informational"=>"Informational", +"Profile"=> "Profile", +"Logout"=> "Logout", +"Home"=>"Home", +"Contact"=> "Contact", +"List of Users"=> "List of Users", +"Send Email"=>"Send Email", +"Welcome to"=> "Welcome to", +"Dashboard v2"=>"Dashboard v2", +"Serial"=> "Serial", +"Email"=> "Email", +"Name"=> "Name", +"Role":=>"Role", +"Action"=>"Action", +"Edit"=> "Edit", +"Delete"=>"Delete", +"Username"=>"Username", +"Password"=>"Password", +"User Role"=> "User Role", +"Submit"=>"Submit" +]; \ No newline at end of file diff --git a/lang/ne.json b/lang/ne.json deleted file mode 100644 index 88502e3..0000000 --- a/lang/ne.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Dashboard":"ड्यासबोर्ड" -} \ No newline at end of file diff --git a/lang/ne/message.php b/lang/ne/message.php new file mode 100644 index 0000000..e972194 --- /dev/null +++ b/lang/ne/message.php @@ -0,0 +1,44 @@ + "ड्यासबोर्ड", + "Charts" => "चार्टहरू", + + "User Management" => "प्रयोगकर्ता व्यवस्थापन", + "All Users" => "सबै प्रयोगकर्ताहरू", + "Add Users" => "प्रयोगकर्ताहरू थप्नुहोस्", + "UI Elements" => "UI तत्त्वहरू", + "Forms" => "फारमहरू", + "Tables" => "तालिकाहरू", + "EXAMPLES" => "उदाहरणहरू", + "Calendar" => "पात्रो", + "Gallery" => "ग्यालरी", + "Kanban Board" => "कानबान बोर्ड", + "Mailbox" => "मेलबक्स", + "Pages" => "पृष्ठहरू", + "Extras" => "थप", + "Search" => "खोजी", + "MISCELLANEOUS" => "विविध", + "Documentation" => "कागजात", + "LABELS" => "लेबलहरू", + "Important" => "महत्त्वपूर्ण", + "Informational" => "सूचनात्मक", + "Profile" => "प्रोफाइल", + "Logout" => "लगआउट", + "Home" => "गृह", + "Contact" => "सम्पर्क", + "List of Users" => "प्रयोगकर्ताहरूको सूची", + "Send Email" => "इमेल पठाउनुहोस्", + "Welcome to" => " स्वागत छ", + "Dashboard v2" => "ड्यासबोर्ड v2", + "Serial" => "सिरियल", + "Email" => "इमेल", + "Name" => "नाम", + "Role" => "भूमिका", + "Action" => "कार्य", + "Edit" => "सम्पादन गर्नुहोस्", + "Delete" => "हटाउनुहोस्", + "Username" => "प्रयोगकर्ता नाम", + "Password" => "पासवर्ड", + "User Role" => "प्रयोगकर्ता भूमिका", + "Submit" => "पेश गर्नुहोस्" +]; diff --git a/resources/old lang/en/auth.php b/resources/lang/en/auth.php similarity index 100% rename from resources/old lang/en/auth.php rename to resources/lang/en/auth.php diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php new file mode 100644 index 0000000..1302682 --- /dev/null +++ b/resources/lang/en/messages.php @@ -0,0 +1,11 @@ + 'User Added Successfully', + 'user_added_error' => 'User Added Unsuccessfully', + 'user_updated_success' => 'User Updated Successfully', + 'user_updated_error' => 'User is not Updated', + 'email_sent_success' => 'Email Sent Successfully', + 'email_sent_error' => 'An error occurred while sending the email.', + // Add more keys as needed +]; diff --git a/resources/old lang/en/pagination.php b/resources/lang/en/pagination.php similarity index 100% rename from resources/old lang/en/pagination.php rename to resources/lang/en/pagination.php diff --git a/resources/old lang/en/passwords.php b/resources/lang/en/passwords.php similarity index 100% rename from resources/old lang/en/passwords.php rename to resources/lang/en/passwords.php diff --git a/resources/old lang/en/validation.php b/resources/lang/en/validation.php similarity index 100% rename from resources/old lang/en/validation.php rename to resources/lang/en/validation.php diff --git a/resources/lang/ne.json b/resources/lang/ne.json new file mode 100644 index 0000000..644db09 --- /dev/null +++ b/resources/lang/ne.json @@ -0,0 +1,43 @@ +{ + "Dashboard": "ड्यासबोर्ड", + "Charts": "चार्टहरू", + "": "", + "User Management": "प्रयोगकर्ता व्यवस्थापन", + "All Users": "सबै प्रयोगकर्ताहरू", + "Add Users": "प्रयोगकर्ताहरू थप्नुहोस्", + "UI Elements": "UI तत्त्वहरू", + "Forms": "फारमहरू", + "Tables": "तालिकाहरू", + "EXAMPLES": "उदाहरणहरू", + "Calendar": "पात्रो", + "Gallery": "ग्यालरी", + "Kanban Board": "कानबान बोर्ड", + "Mailbox": "मेलबक्स", + "Pages": "पृष्ठहरू", + "Extras": "थप", + "Search": "खोजी", + "MISCELLANEOUS": "विविध", + "Documentation": "कागजात", + "LABELS": "लेबलहरू", + "Important": "महत्त्वपूर्ण", + "Informational": "सूचनात्मक", + "Profile": "प्रोफाइल", + "Logout": "लगआउट", + "Home": "गृह", + "Contact": "सम्पर्क", + "List of Users": "प्रयोगकर्ताहरूको सूची", + "Send Email": "इमेल पठाउनुहोस्", + "Welcome to": " स्वागत छ", + "Dashboard v2": "ड्यासबोर्ड v2", + "Serial": "सिरियल", + "Email": "इमेल", + "Name": "नाम", + "Role": "भूमिका", + "Action": "कार्य", + "Edit": "सम्पादन गर्नुहोस्", + "Delete": "हटाउनुहोस्", + "Username": "प्रयोगकर्ता नाम", + "Password": "पासवर्ड", + "User Role": "प्रयोगकर्ता भूमिका", + "Submit": "पेश गर्नुहोस्" +} diff --git a/resources/lang/ne/messages.php b/resources/lang/ne/messages.php new file mode 100644 index 0000000..89a7a43 --- /dev/null +++ b/resources/lang/ne/messages.php @@ -0,0 +1,13 @@ + "ड्यासबोर्ड", + 'user_added_success' => 'प्रयोगकर्ता सफलतापूर्वक थपियो', + 'user_added_error' => 'प्रयोगकर्ता थप्न असफल भयो', + 'user_updated_success' => 'प्रयोगकर्ता सफलतापूर्वक अद्यावधिक गरियो', + 'user_updated_error' => 'प्रयोगकर्ता अद्यावधिक गरिएन', + 'email_sent_success' => 'इमेल सफलतापूर्वक पठाइयो', + 'email_sent_error' => 'इमेल पठाउँदा त्रुटि भयो', + + // Add more keys as needed +]; diff --git a/resources/old lang/en/messages.php b/resources/old lang/en/messages.php deleted file mode 100644 index 0f3c349..0000000 --- a/resources/old lang/en/messages.php +++ /dev/null @@ -1,7 +0,0 @@ - 'Welcome', - 'user_list' => 'List of Users', - // Add more translations here -]; diff --git a/resources/old lang/np/messages.php b/resources/old lang/np/messages.php deleted file mode 100644 index 804eee8..0000000 --- a/resources/old lang/np/messages.php +++ /dev/null @@ -1,7 +0,0 @@ - 'स्वागत छ', - 'user_list' => 'प्रयोगकर्ताहरूको सूची', - // Add more translations here -]; diff --git a/resources/views/backend/layouts/app.blade.php b/resources/views/backend/layouts/app.blade.php index f5f94fd..d4c510a 100644 --- a/resources/views/backend/layouts/app.blade.php +++ b/resources/views/backend/layouts/app.blade.php @@ -78,6 +78,7 @@ + @@ -117,6 +118,8 @@ + + @yield('script') @@ -292,6 +295,15 @@ }); + + diff --git a/resources/views/backend/layouts/dashboard.blade.php b/resources/views/backend/layouts/dashboard.blade.php index 063c71b..95d1a63 100644 --- a/resources/views/backend/layouts/dashboard.blade.php +++ b/resources/views/backend/layouts/dashboard.blade.php @@ -6,12 +6,12 @@
-

Dashboard v2

+

{{ __('Dashboard v2') }}

@@ -90,7 +90,7 @@
-
{{ auth()->user()->role }} - Dashboard
+
{{ auth()->user()->role }} - {{ __('Dashboard') }}
+ @@ -66,11 +67,11 @@ - Serial - Name - Email - Role - Action + {{ __('Serial') }} + {{ __('Name') }} + {{ __('Email') }}Email + {{ __('Role') }} + {{ __('Action') }} diff --git a/routes/web.php b/routes/web.php index 55c3998..8c59459 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,8 @@ use App\Http\Controllers\ProfileController; use App\Http\Controllers\MailController; +use App\Http\Controllers\LangController; + use App\Http\Controllers\backend\UserController; use Illuminate\Support\Facades\Route; @@ -67,11 +69,4 @@ Route::post('/send-email', [App\Http\Controllers\backend\UserController::class, // Route for setting the locale -Route::get('/lang/{locale}', function ($locale) { - Session::put('locale', $locale); - return redirect()->back(); -})->name('setLocale'); - - - -Route::get('set-locale/{locale}', [App\Http\Controllers\LocaleController::class, 'setLocale'])->name('setLocale'); +Route::get('/lang/change', [App\Http\Controllers\LangController::class, 'change'])->name('changelang');