Skip to content

Commit 41ecd77

Browse files
[9.x] Fix overriding global locale (#43426)
* Fix overriding global locale * wip * formatting * Update Request.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 1c15b40 commit 41ecd77

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/Illuminate/Http/Request.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ public static function createFrom(self $from, $to = null)
451451

452452
$request->headers->replace($from->headers->all());
453453

454-
$request->setLocale($from->getLocale());
454+
$request->setRequestLocale($from->getLocale());
455455

456-
$request->setDefaultLocale($from->getDefaultLocale());
456+
$request->setDefaultRequestLocale($from->getDefaultLocale());
457457

458458
$request->setJson($from->json());
459459

@@ -572,6 +572,28 @@ public function setLaravelSession($session)
572572
$this->session = $session;
573573
}
574574

575+
/**
576+
* Set the locale for the request instance.
577+
*
578+
* @param string $locale
579+
* @return void
580+
*/
581+
public function setRequestLocale(string $locale)
582+
{
583+
$this->locale = $locale;
584+
}
585+
586+
/**
587+
* Set the default locale for the request instance.
588+
*
589+
* @param string $locale
590+
* @return void
591+
*/
592+
public function setDefaultRequestLocale(string $locale)
593+
{
594+
$this->defaultLocale = $locale;
595+
}
596+
575597
/**
576598
* Get the user making the request.
577599
*

0 commit comments

Comments
 (0)