mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 08:34:39 -04:00
Clean up for locale resolution?
This commit is contained in:
parent
2757f3ef81
commit
6eb63c14f1
@ -17,6 +17,48 @@ use Illuminate\Support\Facades\App;
|
|||||||
|
|
||||||
class Locale
|
class Locale
|
||||||
{
|
{
|
||||||
|
private array $locales = [
|
||||||
|
'en',
|
||||||
|
'it',
|
||||||
|
'de',
|
||||||
|
'fr',
|
||||||
|
'pt_BR',
|
||||||
|
'nl',
|
||||||
|
'es',
|
||||||
|
'nb_NO',
|
||||||
|
'da',
|
||||||
|
'ja',
|
||||||
|
'sv',
|
||||||
|
'es_ES',
|
||||||
|
'fr_CA',
|
||||||
|
'lt',
|
||||||
|
'pl',
|
||||||
|
'cs',
|
||||||
|
'hr',
|
||||||
|
'sq',
|
||||||
|
'el',
|
||||||
|
'en_GB',
|
||||||
|
'pt_PT',
|
||||||
|
'sl',
|
||||||
|
'fi',
|
||||||
|
'ro',
|
||||||
|
'tr_TR',
|
||||||
|
'th',
|
||||||
|
'mk_MK',
|
||||||
|
'zh_TW',
|
||||||
|
'ru_RU',
|
||||||
|
'ar',
|
||||||
|
'fa',
|
||||||
|
'lv_LV',
|
||||||
|
'sr',
|
||||||
|
'sk',
|
||||||
|
'et',
|
||||||
|
'bg',
|
||||||
|
'he',
|
||||||
|
'km_KH',
|
||||||
|
'hu',
|
||||||
|
'fr_CH',
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
@ -25,10 +67,10 @@ class Locale
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
/*LOCALE SET */
|
/*LOCALE SET */
|
||||||
if ($request->has('lang') && is_string($request->input('lang'))) {
|
if ($request->has('lang') && in_array($request->input('lang','en'), $this->locales) ) {
|
||||||
$locale = $request->string('lang','en');
|
$locale = $request->input('lang');
|
||||||
App::setLocale($locale);
|
App::setLocale($locale);
|
||||||
} elseif (auth()->guard('contact')->user()) {
|
} elseif (auth()->guard('contact')->user()) {
|
||||||
App::setLocale(auth()->guard('contact')->user()->client()->setEagerLoads([])->first()->locale());
|
App::setLocale(auth()->guard('contact')->user()->client()->setEagerLoads([])->first()->locale());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user