diff --git a/.env.example b/.env.example index be3f7021..29841695 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7aea78bf..9b2e1fcd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -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 ], ]; diff --git a/app/Http/Middleware/CreditsDisplayName.php b/app/Http/Middleware/GlobalNames.php similarity index 64% rename from app/Http/Middleware/CreditsDisplayName.php rename to app/Http/Middleware/GlobalNames.php index a6962f41..519b111d 100644 --- a/app/Http/Middleware/CreditsDisplayName.php +++ b/app/Http/Middleware/GlobalNames.php @@ -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); } } diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php index 71926b06..c87e891d 100644 --- a/app/Http/Middleware/SetLocale.php +++ b/app/Http/Middleware/SetLocale.php @@ -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); diff --git a/config/app.php b/config/app.php index b5310c03..b3abcb90 100644 --- a/config/app.php +++ b/config/app.php @@ -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 diff --git a/resources/lang/it.json b/resources/lang/it.json index 4a66a240..8916d17e 100644 --- a/resources/lang/it.json +++ b/resources/lang/it.json @@ -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!" } diff --git a/resources/lang/zh.json b/resources/lang/zh.json index 0fbb56d9..a5116217 100644 --- a/resources/lang/zh.json +++ b/resources/lang/zh.json @@ -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!": "您的请求已处理成功" } diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index b014e2c9..453258e6 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -44,25 +44,29 @@ {{__('Home')}} - + @@ -285,23 +291,23 @@ -{{-- --}} + {{-- --}} -{{-- --}} + {{-- --}} -{{-- --}} + {{-- --}} @@ -351,7 +357,9 @@ @if(Auth::user()->created_at->diffInHours(now(), false) > 1)
{{__('Warning!')}}
- {{__('You have not yet verified your email address')}} {{__('Click here to resend verification email')}}
+ {{__('You have not yet verified your email address')}} {{__('Click here to resend verification email')}} +
{{__('Please contact support If you didnt receive your verification email.')}}
@endif @@ -365,7 +373,8 @@ @@ -398,15 +407,15 @@