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 @@