mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #14401 from uberbrady/fix_locale_warning
Fix [sc-25008] - correct and improve legacy language warnings
This commit is contained in:
commit
7bae4c39c6
|
@ -8,6 +8,12 @@ use \App\Helpers\Helper;
|
|||
|
||||
class CheckLocale
|
||||
{
|
||||
private function warn_legacy_locale($language, $source)
|
||||
{
|
||||
if ($language != Helper::mapLegacyLocale($language)) {
|
||||
\Log::warning("$source $language and should be updated to be ".Helper::mapLegacyLocale($language));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle the locale for the user, default to settings otherwise.
|
||||
*
|
||||
|
@ -22,24 +28,23 @@ class CheckLocale
|
|||
|
||||
// Default app settings from config
|
||||
$language = config('app.locale');
|
||||
$this->warn_legacy_locale($language, "APP_LOCALE in .env is set to");
|
||||
|
||||
if ($settings = Setting::getSettings()) {
|
||||
|
||||
// User's preference
|
||||
if (($request->user()) && ($request->user()->locale)) {
|
||||
$language = $request->user()->locale;
|
||||
$this->warn_legacy_locale($language, "username ".$request->user()->username." (".$request->user()->id.") has a language");
|
||||
|
||||
// App setting preference
|
||||
} elseif ($settings->locale != '') {
|
||||
$language = $settings->locale;
|
||||
$this->warn_legacy_locale($language, "App Settings is set to");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (config('app.locale') != Helper::mapLegacyLocale($language)) {
|
||||
\Log::warning('Your current APP_LOCALE in your .env is set to "'.config('app.locale').'" and should be updated to be "'.Helper::mapLegacyLocale($language).'" in '.base_path().'/.env. Translations may display unexpectedly until this is updated.');
|
||||
}
|
||||
|
||||
\App::setLocale(Helper::mapLegacyLocale($language));
|
||||
return $next($request);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue