Skip to content

Commit

Permalink
FRW-6369 Fixed issues with Dynamic Multistore. (#10757)
Browse files Browse the repository at this point in the history
FRW-6369 Fixed issues with Dynamic Multistore.
  • Loading branch information
olhalivitchuk authored Feb 12, 2024
1 parent 5161726 commit 104480d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Spryker/Glue/Locale/Negotiator/LanguageNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getLanguageIsoCode(?string $headerAcceptLanguage = null): string
}

if (!$headerAcceptLanguage) {
return $this->getDefaultLanguage();
return $this->getDefaultLanguage($storeLocaleCodes);
}

foreach ($storeLocaleCodes as $localeName) {
Expand All @@ -72,21 +72,23 @@ public function getLanguageIsoCode(?string $headerAcceptLanguage = null): string
$acceptLanguageTransfer = $this->localeService->getAcceptLanguage($headerAcceptLanguage, array_keys($storeLocaleCodes));

if (!$acceptLanguageTransfer || $acceptLanguageTransfer->getType() === null) {
return $this->getDefaultLanguage();
return $this->getDefaultLanguage($storeLocaleCodes);
}

if (!isset($storeLocaleCodes[$acceptLanguageTransfer->getType()])) {
return $this->getDefaultLanguage();
return $this->getDefaultLanguage($storeLocaleCodes);
}

return $storeLocaleCodes[$acceptLanguageTransfer->getType()];
}

/**
* @param array<string, string> $storeLocaleCodes
*
* @return string
*/
protected function getDefaultLanguage(): string
protected function getDefaultLanguage(array $storeLocaleCodes): string
{
return $this->storeClient->getCurrentStore()->getDefaultLocaleIsoCodeOrFail();
return $this->storeClient->getCurrentStore()->getDefaultLocaleIsoCode() ?? (string)array_shift($storeLocaleCodes);
}
}

0 comments on commit 104480d

Please sign in to comment.