Option to disable certain languages completely
This commit is contained in:
parent
4b99893ee6
commit
72b25e53c3
8 changed files with 280 additions and 46 deletions
|
@ -8,11 +8,17 @@ APP_TIMEZONE=UTC
|
|||
|
||||
# If set to true, Language is chosen automatically depending on the users browserlanguage.
|
||||
DYNAMIC_LOCALE = false
|
||||
|
||||
# The language of the Dashboard. This is also the fallback if dynamic_locale is true but no translation is found
|
||||
LOCALE=en
|
||||
|
||||
# You can grab the Language-Codes for the Datatables from this Website https://datatables.net/plug-ins/i18n/
|
||||
DATATABLE_LOCALE=en-gb
|
||||
|
||||
#The languages you DO NOT want to support on your Controlpanel split by comma.
|
||||
#Remove the language to make it available
|
||||
UNSUPPORTED_LOCALES=german,italian,chinese
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http;
|
|||
|
||||
use App\Http\Middleware\ApiAuthToken;
|
||||
use App\Http\Middleware\CheckSuspended;
|
||||
use App\Http\Middleware\CreditsDisplayName;
|
||||
use App\Http\Middleware\GlobalNames;
|
||||
use App\Http\Middleware\isAdmin;
|
||||
use App\Http\Middleware\LastSeen;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
@ -43,14 +43,14 @@ class Kernel extends HttpKernel
|
|||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
LastSeen::class,
|
||||
CreditsDisplayName::class,
|
||||
GlobalNames::class,
|
||||
\App\Http\Middleware\SetLocale::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
CreditsDisplayName::class
|
||||
GlobalNames::class
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use App\Models\Configuration;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreditsDisplayName
|
||||
class GlobalNames
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
|
@ -18,6 +18,11 @@ class CreditsDisplayName
|
|||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
define('CREDITS_DISPLAY_NAME' , Configuration::getValueByKey('CREDITS_DISPLAY_NAME' , 'Credits'));
|
||||
|
||||
$unsupported_lang_array = explode(',', config("app.unsupported_locales"));
|
||||
$unsupported_lang_array = array_map( 'strtolower', $unsupported_lang_array );
|
||||
define('UNSUPPORTED_LANGS', $unsupported_lang_array);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,195 @@ use Illuminate\Support\Facades\Session;
|
|||
|
||||
class SetLocale
|
||||
{
|
||||
function getLocaleCodeForDisplayLanguage($name){
|
||||
$languageCodes = array(
|
||||
"aa" => "Afar",
|
||||
"ab" => "Abkhazian",
|
||||
"ae" => "Avestan",
|
||||
"af" => "Afrikaans",
|
||||
"ak" => "Akan",
|
||||
"am" => "Amharic",
|
||||
"an" => "Aragonese",
|
||||
"ar" => "Arabic",
|
||||
"as" => "Assamese",
|
||||
"av" => "Avaric",
|
||||
"ay" => "Aymara",
|
||||
"az" => "Azerbaijani",
|
||||
"ba" => "Bashkir",
|
||||
"be" => "Belarusian",
|
||||
"bg" => "Bulgarian",
|
||||
"bh" => "Bihari",
|
||||
"bi" => "Bislama",
|
||||
"bm" => "Bambara",
|
||||
"bn" => "Bengali",
|
||||
"bo" => "Tibetan",
|
||||
"br" => "Breton",
|
||||
"bs" => "Bosnian",
|
||||
"ca" => "Catalan",
|
||||
"ce" => "Chechen",
|
||||
"ch" => "Chamorro",
|
||||
"co" => "Corsican",
|
||||
"cr" => "Cree",
|
||||
"cs" => "Czech",
|
||||
"cu" => "Church Slavic",
|
||||
"cv" => "Chuvash",
|
||||
"cy" => "Welsh",
|
||||
"da" => "Danish",
|
||||
"de" => "German",
|
||||
"dv" => "Divehi",
|
||||
"dz" => "Dzongkha",
|
||||
"ee" => "Ewe",
|
||||
"el" => "Greek",
|
||||
"en" => "English",
|
||||
"eo" => "Esperanto",
|
||||
"es" => "Spanish",
|
||||
"et" => "Estonian",
|
||||
"eu" => "Basque",
|
||||
"fa" => "Persian",
|
||||
"ff" => "Fulah",
|
||||
"fi" => "Finnish",
|
||||
"fj" => "Fijian",
|
||||
"fo" => "Faroese",
|
||||
"fr" => "French",
|
||||
"fy" => "Western Frisian",
|
||||
"ga" => "Irish",
|
||||
"gd" => "Scottish Gaelic",
|
||||
"gl" => "Galician",
|
||||
"gn" => "Guarani",
|
||||
"gu" => "Gujarati",
|
||||
"gv" => "Manx",
|
||||
"ha" => "Hausa",
|
||||
"he" => "Hebrew",
|
||||
"hi" => "Hindi",
|
||||
"ho" => "Hiri Motu",
|
||||
"hr" => "Croatian",
|
||||
"ht" => "Haitian",
|
||||
"hu" => "Hungarian",
|
||||
"hy" => "Armenian",
|
||||
"hz" => "Herero",
|
||||
"ia" => "Interlingua (International Auxiliary Language Association)",
|
||||
"id" => "Indonesian",
|
||||
"ie" => "Interlingue",
|
||||
"ig" => "Igbo",
|
||||
"ii" => "Sichuan Yi",
|
||||
"ik" => "Inupiaq",
|
||||
"io" => "Ido",
|
||||
"is" => "Icelandic",
|
||||
"it" => "Italian",
|
||||
"iu" => "Inuktitut",
|
||||
"ja" => "Japanese",
|
||||
"jv" => "Javanese",
|
||||
"ka" => "Georgian",
|
||||
"kg" => "Kongo",
|
||||
"ki" => "Kikuyu",
|
||||
"kj" => "Kwanyama",
|
||||
"kk" => "Kazakh",
|
||||
"kl" => "Kalaallisut",
|
||||
"km" => "Khmer",
|
||||
"kn" => "Kannada",
|
||||
"ko" => "Korean",
|
||||
"kr" => "Kanuri",
|
||||
"ks" => "Kashmiri",
|
||||
"ku" => "Kurdish",
|
||||
"kv" => "Komi",
|
||||
"kw" => "Cornish",
|
||||
"ky" => "Kirghiz",
|
||||
"la" => "Latin",
|
||||
"lb" => "Luxembourgish",
|
||||
"lg" => "Ganda",
|
||||
"li" => "Limburgish",
|
||||
"ln" => "Lingala",
|
||||
"lo" => "Lao",
|
||||
"lt" => "Lithuanian",
|
||||
"lu" => "Luba-Katanga",
|
||||
"lv" => "Latvian",
|
||||
"mg" => "Malagasy",
|
||||
"mh" => "Marshallese",
|
||||
"mi" => "Maori",
|
||||
"mk" => "Macedonian",
|
||||
"ml" => "Malayalam",
|
||||
"mn" => "Mongolian",
|
||||
"mr" => "Marathi",
|
||||
"ms" => "Malay",
|
||||
"mt" => "Maltese",
|
||||
"my" => "Burmese",
|
||||
"na" => "Nauru",
|
||||
"nb" => "Norwegian Bokmal",
|
||||
"nd" => "North Ndebele",
|
||||
"ne" => "Nepali",
|
||||
"ng" => "Ndonga",
|
||||
"nl" => "Dutch",
|
||||
"nn" => "Norwegian Nynorsk",
|
||||
"no" => "Norwegian",
|
||||
"nr" => "South Ndebele",
|
||||
"nv" => "Navajo",
|
||||
"ny" => "Chichewa",
|
||||
"oc" => "Occitan",
|
||||
"oj" => "Ojibwa",
|
||||
"om" => "Oromo",
|
||||
"or" => "Oriya",
|
||||
"os" => "Ossetian",
|
||||
"pa" => "Panjabi",
|
||||
"pi" => "Pali",
|
||||
"pl" => "Polish",
|
||||
"ps" => "Pashto",
|
||||
"pt" => "Portuguese",
|
||||
"qu" => "Quechua",
|
||||
"rm" => "Raeto-Romance",
|
||||
"rn" => "Kirundi",
|
||||
"ro" => "Romanian",
|
||||
"ru" => "Russian",
|
||||
"rw" => "Kinyarwanda",
|
||||
"sa" => "Sanskrit",
|
||||
"sc" => "Sardinian",
|
||||
"sd" => "Sindhi",
|
||||
"se" => "Northern Sami",
|
||||
"sg" => "Sango",
|
||||
"si" => "Sinhala",
|
||||
"sk" => "Slovak",
|
||||
"sl" => "Slovenian",
|
||||
"sm" => "Samoan",
|
||||
"so" => "Somali",
|
||||
"sq" => "Albanian",
|
||||
"sr" => "Serbian",
|
||||
"ss" => "Swati",
|
||||
"st" => "Southern Sotho",
|
||||
"su" => "Sundanese",
|
||||
"sv" => "Swedish",
|
||||
"sw" => "Swahili",
|
||||
"ta" => "Tamil",
|
||||
"te" => "Telugu",
|
||||
"tg" => "Tajik",
|
||||
"th" => "Thai",
|
||||
"ti" => "Tigrinya",
|
||||
"tk" => "Turkmen",
|
||||
"tl" => "Tagalog",
|
||||
"tn" => "Tswana",
|
||||
"to" => "Tonga",
|
||||
"tr" => "Turkish",
|
||||
"ts" => "Tsonga",
|
||||
"tt" => "Tatar",
|
||||
"tw" => "Twi",
|
||||
"ty" => "Tahitian",
|
||||
"ug" => "Uighur",
|
||||
"uk" => "Ukrainian",
|
||||
"ur" => "Urdu",
|
||||
"uz" => "Uzbek",
|
||||
"ve" => "Venda",
|
||||
"vi" => "Vietnamese",
|
||||
"vo" => "Volapuk",
|
||||
"wa" => "Walloon",
|
||||
"wo" => "Wolof",
|
||||
"xh" => "Xhosa",
|
||||
"yi" => "Yiddish",
|
||||
"yo" => "Yoruba",
|
||||
"za" => "Zhuang",
|
||||
"zh" => "Chinese",
|
||||
"zu" => "Zulu"
|
||||
);
|
||||
return array_search($name, array_flip($languageCodes));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Handle an incoming request.
|
||||
|
@ -19,18 +208,22 @@ class SetLocale
|
|||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if (Session::has('locale')) {
|
||||
$locale = Session::get('locale', config('app.locale'));
|
||||
} else {
|
||||
if (config('app.dynamic_locale')) {
|
||||
if (!config('app.dynamic_locale')) {
|
||||
$locale = config('app.locale');
|
||||
}else{
|
||||
$locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2);
|
||||
|
||||
if (!in_array($locale, config('app.available_locales'))) {
|
||||
if (!in_array($locale, config('app.available_locales'))
|
||||
|| in_array(strtolower($this->getLocaleCodeForDisplayLanguage($locale)), UNSUPPORTED_LANGS)) {
|
||||
$locale = config('app.locale');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
App::setLocale($locale);
|
||||
|
||||
return $next($request);
|
||||
|
|
|
@ -107,6 +107,19 @@ return [
|
|||
'available_locales' => array('English'=>'en','German'=>'de','Italian'=>'it','Chinese'=>'zh'),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Unsupported Locales
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Locales the Owner of the Dashboard does not want to support
|
||||
|
|
||||
|
|
||||
*/
|
||||
|
||||
'unsupported_locales' => env("UNSUPPORTED_LOCALES", ""),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Datatable Language Setting
|
||||
|
|
|
@ -155,6 +155,7 @@
|
|||
"If you did not receive the email": "Se non hai ricevuto l'email",
|
||||
"click here to request another": "clicca qui per richiederne un'altra",
|
||||
"Home": "Home",
|
||||
"Languages": "Lingue",
|
||||
"See all Notifications": "Vedi tutte le notifiche",
|
||||
"Profile": "Profilo",
|
||||
"Log back in": "Fai il login di nuovo",
|
||||
|
@ -297,10 +298,10 @@
|
|||
"Invoice Settings": "Impostazioni fattura",
|
||||
"Download all Invoices": "Scarica tutte le fatture",
|
||||
"Enter your companys name": "Inserisci il nome della tua azienda",
|
||||
"Enter your companys adress": "Inserisci l’indirzzo della tua azienda",
|
||||
"Enter your companys address": "Inserisci l'indirizzo della tua azienda",
|
||||
"Enter your companys phone number": "Inserisci il numero di telefono dell'azienda",
|
||||
"Enter your companys VAT id": "Inserisci il numero di partita IVA della tua azienda",
|
||||
"Enter your companys email adress": "Inserisci l’indirizzo email della tua azienda",
|
||||
"Enter your companys email address": "Inserisci l’indirizzo email della tua azienda",
|
||||
"Enter your companys website": "Inserisci il sito della tua azienda",
|
||||
"Enter your custom invoice prefix": "Inserisci il prefisso personalizzato della fattura",
|
||||
"Select Invoice Logo": "Inserisci il logo della fattura",
|
||||
|
@ -320,5 +321,8 @@
|
|||
"Delete": "Elimina",
|
||||
"Login as User": "Accedi come utente",
|
||||
"Clone": "Clona",
|
||||
"Amount due": "Importo dovuto"
|
||||
"Amount due": "Importo dovuto",
|
||||
"Your Payment was successful!": "Pagamento effettuato con successo!",
|
||||
"Hello": "Ciao",
|
||||
"Your payment was processed successfully!": "Il pagamento è stato effettuato con successo!"
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@
|
|||
"If you did not receive the email": "如果您没有收到该邮件",
|
||||
"click here to request another": "请点击这里申请另一个",
|
||||
"Home": "首页",
|
||||
"Languages": "语言",
|
||||
"See all Notifications": "查看所有通知",
|
||||
"Profile": "简介",
|
||||
"Log back in": "重新登录",
|
||||
|
@ -297,10 +298,10 @@
|
|||
"Invoice Settings": "发票设置",
|
||||
"Download all Invoices": "下载所有发票",
|
||||
"Enter your companys name": "输入你的公司名称",
|
||||
"Enter your companys adress": "输入你的公司的地址",
|
||||
"Enter your companys address": "输入你的公司的地址",
|
||||
"Enter your companys phone number": "输入你的公司的电话号码",
|
||||
"Enter your companys VAT id": "输入你的公司的增值税识别码",
|
||||
"Enter your companys email adress": "输入公司的电子邮件地址",
|
||||
"Enter your companys email address": "输入公司的电子邮件地址",
|
||||
"Enter your companys website": "输入你的公司网站",
|
||||
"Enter your custom invoice prefix": "输入你的自定义发票前缀",
|
||||
"Select Invoice Logo": "选择发票标志",
|
||||
|
@ -320,5 +321,8 @@
|
|||
"Delete": "删除",
|
||||
"Login as User": "以用户身份登录",
|
||||
"Clone": "克隆",
|
||||
"Amount due": "应付金额"
|
||||
"Amount due": "应付金额",
|
||||
"Your Payment was successful!": "恭喜,您的订单支付成功 !",
|
||||
"Hello": "您好",
|
||||
"Your payment was processed successfully!": "您的请求已处理成功"
|
||||
}
|
||||
|
|
|
@ -44,25 +44,29 @@
|
|||
<a href="{{route('home')}}" class="nav-link"><i class="fas fa-home mr-2"></i>{{__('Home')}}</a>
|
||||
</li>
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<a href="{{env('DISCORD_INVITE_URL')}}" class="nav-link" target="__blank"><i class="fab fa-discord mr-2"></i>{{__('Discord')}}</a>
|
||||
<a href="{{env('DISCORD_INVITE_URL')}}" class="nav-link" target="__blank"><i
|
||||
class="fab fa-discord mr-2"></i>{{__('Discord')}}</a>
|
||||
</li>
|
||||
<!-- Language Selection -->
|
||||
<!-- Language Selection -->
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link" href="#" id="languageDropdown" role="button" data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false">
|
||||
<span class="mr-1 d-lg-inline text-gray-600">
|
||||
<small><i class="fa fa-language mr-2"></i></small>{{__("Languages"}}
|
||||
<small><i class="fa fa-language mr-2"></i></small>{{__("Languages")}}
|
||||
</span>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="changeLocale">
|
||||
<form method="post" action="{{route('changeLocale')}}" class="nav-item text-center">
|
||||
@csrf
|
||||
@foreach (config("app.available_locales") as $key=>$value)
|
||||
<button class="dropdown-item" name="inputLocale" value="{{$value}}">
|
||||
{{$key}}
|
||||
</button>
|
||||
@endforeach
|
||||
@foreach (config("app.available_locales") as $key=>$value)
|
||||
@if(!in_array(strtolower($key),UNSUPPORTED_LANGS))
|
||||
<button class="dropdown-item" name="inputLocale" value="{{$value}}">
|
||||
{{$key}}
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
@ -82,7 +86,8 @@
|
|||
@endif
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
|
||||
<span class="dropdown-item dropdown-header">{{Auth::user()->unreadNotifications->count()}} {{__('Notifications')}}</span>
|
||||
<span
|
||||
class="dropdown-item dropdown-header">{{Auth::user()->unreadNotifications->count()}} {{__('Notifications')}}</span>
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
@foreach(Auth::user()->unreadNotifications->sortBy('created_at')->take(5) as $notification)
|
||||
|
@ -95,7 +100,8 @@
|
|||
@endforeach
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="{{route('notifications.index')}}" class="dropdown-item dropdown-footer">{{__('See all Notifications')}}</a>
|
||||
<a href="{{route('notifications.index')}}"
|
||||
class="dropdown-item dropdown-footer">{{__('See all Notifications')}}</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
@ -285,23 +291,23 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
{{-- <li class="nav-header">Pterodactyl</li>--}}
|
||||
{{-- <li class="nav-header">Pterodactyl</li>--}}
|
||||
|
||||
{{-- <li class="nav-item">--}}
|
||||
{{-- <a href="{{route('admin.nodes.index')}}"--}}
|
||||
{{-- class="nav-link @if(Request::routeIs('admin.nodes.*')) active @endif">--}}
|
||||
{{-- <i class="nav-icon fas fa-sitemap"></i>--}}
|
||||
{{-- <p>Nodes</p>--}}
|
||||
{{-- </a>--}}
|
||||
{{-- </li>--}}
|
||||
{{-- <li class="nav-item">--}}
|
||||
{{-- <a href="{{route('admin.nodes.index')}}"--}}
|
||||
{{-- class="nav-link @if(Request::routeIs('admin.nodes.*')) active @endif">--}}
|
||||
{{-- <i class="nav-icon fas fa-sitemap"></i>--}}
|
||||
{{-- <p>Nodes</p>--}}
|
||||
{{-- </a>--}}
|
||||
{{-- </li>--}}
|
||||
|
||||
{{-- <li class="nav-item">--}}
|
||||
{{-- <a href="{{route('admin.nests.index')}}"--}}
|
||||
{{-- class="nav-link @if(Request::routeIs('admin.nests.*')) active @endif">--}}
|
||||
{{-- <i class="nav-icon fas fa-th-large"></i>--}}
|
||||
{{-- <p>Nests</p>--}}
|
||||
{{-- </a>--}}
|
||||
{{-- </li>--}}
|
||||
{{-- <li class="nav-item">--}}
|
||||
{{-- <a href="{{route('admin.nests.index')}}"--}}
|
||||
{{-- class="nav-link @if(Request::routeIs('admin.nests.*')) active @endif">--}}
|
||||
{{-- <i class="nav-icon fas fa-th-large"></i>--}}
|
||||
{{-- <p>Nests</p>--}}
|
||||
{{-- </a>--}}
|
||||
{{-- </li>--}}
|
||||
|
||||
|
||||
<li class="nav-header">{{__('Other')}}</li>
|
||||
|
@ -351,7 +357,9 @@
|
|||
@if(Auth::user()->created_at->diffInHours(now(), false) > 1)
|
||||
<div class="alert alert-warning p-2 m-2">
|
||||
<h5><i class="icon fas fa-exclamation-circle"></i> {{__('Warning!')}}</h5>
|
||||
{{__('You have not yet verified your email address')}} <a class="text-primary" href="{{route('verification.send')}}">{{__('Click here to resend verification email')}}</a> <br>
|
||||
{{__('You have not yet verified your email address')}} <a class="text-primary"
|
||||
href="{{route('verification.send')}}">{{__('Click here to resend verification email')}}</a>
|
||||
<br>
|
||||
{{__('Please contact support If you didnt receive your verification email.')}}
|
||||
</div>
|
||||
@endif
|
||||
|
@ -365,7 +373,8 @@
|
|||
<footer class="main-footer">
|
||||
<strong>Copyright © 2021-{{date('Y')}} <a href="{{url('/')}}">{{env('APP_NAME' , 'Laravel')}}</a>.</strong>
|
||||
All rights
|
||||
reserved. Powered by <a href="https://controlpanel.gg">ControlPanel</a>. Version <b>{{config('app')['version']}}</b>
|
||||
reserved. Powered by <a href="https://controlpanel.gg">ControlPanel</a>. Version
|
||||
<b>{{config('app')['version']}}</b>
|
||||
</footer>
|
||||
|
||||
<!-- Control Sidebar -->
|
||||
|
@ -398,15 +407,15 @@
|
|||
<!-- Select2 -->
|
||||
<script src={{asset('plugins/select2/js/select2.min.js')}}>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
|
Loading…
Reference in a new issue