We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88c29bc commit 7df2824Copy full SHA for 7df2824
system/HTTP/IncomingRequest.php
@@ -441,10 +441,14 @@ public function getPath(): string
441
*/
442
public function setLocale(string $locale)
443
{
444
- // If it's not a valid locale, set it
445
- // to the default locale for the site.
+ // Check if valid locale.
446
if (! in_array($locale, $this->validLocales, true)) {
447
- $locale = $this->defaultLocale;
+ // If not valid, check if language only is valid locale.
+ $locale = strtok($locale, '-');
448
+ if (! in_array($locale, $this->validLocales, true)) {
449
+ // If neither valid, use default locale for the site.
450
+ $locale = $this->defaultLocale;
451
+ }
452
}
453
454
$this->locale = $locale;
0 commit comments