diff --git a/app/Classes/Settings/LanguageSettingsC.php b/app/Classes/Settings/LanguageSettingsC.php index 51a84300..d96c3be7 100644 --- a/app/Classes/Settings/LanguageSettingsC.php +++ b/app/Classes/Settings/LanguageSettingsC.php @@ -20,7 +20,7 @@ class LanguageSettingsC public function updateLanguageSettings(Request $request) { - $values=[ + $values = [ //SETTINGS::VALUE => REQUEST-VALUE (coming from the html-form) "SETTINGS::LOCALE:DEFAULT" => "defaultLanguage", "SETTINGS::LOCALE:DYNAMIC" => "autotranslate", @@ -29,9 +29,9 @@ class LanguageSettingsC "SETTINGS::LOCALE:DATATABLES" => "datatable-language" ]; - foreach($values as $key=>$value){ + foreach ($values as $key => $value) { Settings::where('key', $key)->update(['value' => $request->get($value)]); - Cache::forget("setting" .':'. $key); + Cache::forget("setting" . ':' . $key); } diff --git a/app/Http/Controllers/TranslationController.php b/app/Http/Controllers/TranslationController.php index 40a6bd05..d771f8f2 100644 --- a/app/Http/Controllers/TranslationController.php +++ b/app/Http/Controllers/TranslationController.php @@ -18,4 +18,6 @@ class TranslationController extends Controller Session::put('locale', $request->inputLocale); return redirect()->back(); } + + } diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php index 2ca898a6..1af99c01 100644 --- a/app/Http/Middleware/SetLocale.php +++ b/app/Http/Middleware/SetLocale.php @@ -21,20 +21,20 @@ class SetLocale */ public function handle($request, Closure $next) { - if (Session::has('locale')) { - $locale = Session::get('locale', Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT")); + if (Session::has('locale')) { + $locale = Session::get('locale', Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT")); + } else { + if (Settings::getValueByKey("SETTINGS::LOCALE:DYNAMIC") == "false") { + $locale = Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT"); } else { - if (Settings::getValueByKey("SETTINGS::LOCALE:DYNAMIC") == "false") { + $locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2); + + if (!in_array($locale, json_decode(Settings::getValueByKey("SETTINGS::LOCALE:AVAILABLE")))) { $locale = Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT"); - }else{ - $locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2); - - if (!in_array($locale, json_decode(Settings::getValueByKey("SETTINGS::LOCALE:AVAILABLE")))){ - $locale = Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT"); - } - } + } + } App::setLocale($locale); return $next($request); diff --git a/config/app.php b/config/app.php index 5292fdb2..c490961f 100644 --- a/config/app.php +++ b/config/app.php @@ -86,6 +86,19 @@ return [ 'locale' =>"en", + /* + |-------------------------------------------------------------------------- + | Available Languages + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ + + 'available_locales' =>["en","cs","de","es","fr","hi","it","pl","zh"], + /* |-------------------------------------------------------------------------- | Application Fallback Locale diff --git a/resources/views/admin/settings/tabs/language.blade.php b/resources/views/admin/settings/tabs/language.blade.php index 72d98b5d..0aa56e65 100644 --- a/resources/views/admin/settings/tabs/language.blade.php +++ b/resources/views/admin/settings/tabs/language.blade.php @@ -12,10 +12,9 @@ - German - English - French - Czech + @foreach(config("app.available_locales") as $lang) + {{__($lang)}} + @endforeach {{__("Default language")}}: - German - English - French - Czech + {{__(\App\Models\Settings::getValueByKey("SETTINGS::LOCALE:DEFAULT"))}} + @foreach(config("app.available_locales") as $lang) + {{__($lang)}} + @endforeach - Datable Language - - - - - - - {{__('Auto-translate')}} - - - - {{__('Let the Client change the Language')}} - - + Datable Language + - {{ __('Save') }} - + + + {{__('Auto-translate')}} + + + + {{__('Let the Client change the Language')}} + + + + + +{{ __('Save') }} + diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index 7b59f784..29e1fa9c 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -8,440 +8,446 @@ {{ config('app.name', 'Laravel') }} + href="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('favicon.ico') ? asset('storage/favicon.ico') : asset('favicon.ico') }}" + type="image/x-icon"> {{-- --}} - + {{-- summernote --}} {{-- datetimepicker --}} + href="{{ asset('plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css') }}"> {{-- select2 --}} + onload="this.onload=null;this.rel='stylesheet'"> - - - - - - - - - - {{ __('Home') }} - - - {{ __('Discord') }} - - - @if (\App\Models\Settings::getValueByKey("SETTINGS::LOCALE:CLIENTS_CAN_CHANGE") == 'true') + + + + + + + + + + {{ __('Home') }} + + + {{ __('Discord') }} + + + @if (\App\Models\Settings::getValueByKey("SETTINGS::LOCALE:CLIENTS_CAN_CHANGE") == 'true') + aria-haspopup="true" aria-expanded="false"> {{ __('Language') }} + aria-labelledby="changeLocale"> @csrf @foreach (json_decode(\App\Models\Settings::getValueByKey("SETTINGS::LOCALE:AVAILABLE")) as $key) - - {{ __($key) }} - + + {{ __($key) }} + @endforeach - @endif - + @endif + - + - - - - - - - @if (Auth::user()->unreadNotifications->count() != 0) - {{ Auth::user()->unreadNotifications->count() }} - @endif - - + + + + + + + @if (Auth::user()->unreadNotifications->count() != 0) + {{ Auth::user()->unreadNotifications->count() }} + @endif + + {{ Auth::user()->unreadNotifications->count() }} {{ __('Notifications') }} - + - @foreach (Auth::user()->unreadNotifications->sortBy('created_at')->take(5) - as $notification) - + @foreach (Auth::user()->unreadNotifications->sortBy('created_at')->take(5) +as $notification) + {{ $notification->data['title'] }} - {{ $notification->created_at->longAbsoluteDiffForHumans() }} + {{ $notification->created_at->longAbsoluteDiffForHumans() }} ago - - @endforeach + + @endforeach - - {{ __('See all Notifications') }} - - + + {{ __('See all Notifications') }} + + - - + + {{ Auth::user()->credits() }} + + + + + {{ __('Store') }} - - - - {{ __('Store') }} - - - - - {{ __('Redeem code') }} - - - + + + + {{ __('Redeem code') }} + + + - - + + {{ Auth::user()->name }} + src="{{ Auth::user()->getAvatar() }}"> + + + + + + {{ __('Profile') }} - - - - - {{ __('Profile') }} - - {{-- --}} - {{-- --}} - {{-- Activity Log --}} - {{-- --}} - @if (session()->get('previousUser')) - - - - {{ __('Log back in') }} - - @endif + {{-- --}} + {{-- --}} + {{-- Activity Log --}} + {{-- --}} + @if (session()->get('previousUser')) - - @csrf - - - {{ __('Logout') }} - - - - - - - - - + + + + + +