Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
#[NEW] New language switcher with icons
Browse files Browse the repository at this point in the history
  • Loading branch information
milenmk committed Apr 11, 2023
1 parent 85fb66b commit b09dc2c
Show file tree
Hide file tree
Showing 552 changed files with 46,830 additions and 184 deletions.
26 changes: 24 additions & 2 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,36 @@ class AdminController extends Controller
{

/**
* Show all domains
* Admin main dashboard
*
* @return Application|Factory|View
* @return View|Factory|Application
*/
public static function index(): View|Factory|Application
{

return view('adminboard');
}

/**
* Users view
*
* @return View|Factory|Application
*/
public static function users(): View|Factory|Application
{

return view('admin.users');
}

/**
* Options view
*
* @return View|Factory|Application
*/
public static function options(): View|Factory|Application
{

return view('admin.options');
}

}
34 changes: 34 additions & 0 deletions app/Http/Controllers/LanguageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types = 1);

namespace App\Http\Controllers;

use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use function array_key_exists;

/**
* Language controller
*/
class LanguageController extends Controller
{

/**
* @param string $lang
*
* @return RedirectResponse
*/
public function switchLang(string $lang): RedirectResponse
{

if (array_key_exists($lang, Config::get('languages'))) {
Session::put('applocale', $lang);
}

return Redirect::back();
}

}
17 changes: 13 additions & 4 deletions app/Http/Middleware/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use function array_key_exists;

/**
* Localization middleware
*/
class Localization
{

Expand All @@ -19,12 +24,16 @@ class Localization
* @param Closure $next
*
* @return mixed
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): mixed
{

if (Session::has('locale')) {
App::setLocale(Session::get('locale'));
if (session()->has('applocale') && array_key_exists(session()->get('applocale'), config('languages'))) {
App::setLocale(session()->get('applocale'));
} else { // This is optional as Laravel will automatically set the fallback language if there is none specified
App::setLocale(config('app.fallback_locale'));
}

return $next($request);
Expand Down
145 changes: 0 additions & 145 deletions config/installer.php

This file was deleted.

14 changes: 14 additions & 0 deletions config/languages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types = 1);

return [
'en' => [
'display' => 'English',
'flag-icon' => 'us',
],
'bg' => [
'display' => 'Български',
'flag-icon' => 'bg',
],
];
9 changes: 7 additions & 2 deletions lang/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"of": "от",
"Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.": "След като акаунтът ви бъде изтрит, всички негови ресурси и данни ще бъдат изтрити за постоянно. Преди да изтриете акаунта си, моля, изтеглете всички данни или информация, които искате да запазите.",
"Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.": "След като акаунтът ви бъде изтрит, всички негови ресурси и данни ще бъдат изтрити за постоянно. Моля, въведете паролата си, за да потвърдите, че искате да изтриете завинаги акаунта си.",
"Options": "Настроики",
"Options": "Настройки",
"Pagination Navigation": "Навигация по страници",
"Password": "Парола",
"Profile": "Профил",
Expand Down Expand Up @@ -95,5 +95,10 @@
"View Records": "Покажи записи",
"ViewRecords": "Покажи записи",
"Website": "Уебсайт",
"Your email address is unverified.": "Вашият имейл адрес не е потвърден."
"Your email address is unverified.": "Вашият имейл адрес не е потвърден.",
"auth.failed": "Грешно потребителско име ИЛИ парола",
"Dashboard": "Табло",
"Users": "Потребители",
"Go to site": "Към страницата",
"Administration": "Администрация"
}
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
"View Records": "View Records",
"ViewRecords": "View Records",
"Website": "Website",
"Your email address is unverified.": "Your email address is unverified."
"Your email address is unverified.": "Your email address is unverified.",
"auth.failed": "Wrong username OR password"
}
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
"postcss": "^8.4.6",
"tailwindcss": "^3.1.0",
"vite": "^4.0.0"
},
"dependencies": {
"flag-icon-css": "^4.1.7"
}
}
Loading

0 comments on commit b09dc2c

Please sign in to comment.