diff --git a/Classes/Negotiation/DefaultNegotiation.php b/Classes/Negotiation/DefaultNegotiation.php index bbcec4a..8bf3159 100644 --- a/Classes/Negotiation/DefaultNegotiation.php +++ b/Classes/Negotiation/DefaultNegotiation.php @@ -13,19 +13,18 @@ public function __construct(protected Normalizer $normalizer) {} public function __invoke(NegotiateSiteLanguageEvent $event): void { - $compareWith = [ - 'getLocale', - 'getTwoLetterIsoCode', - ]; - $userLanguages = $this->normalizer->normalizeList($event->getUserLanguages()); foreach ($userLanguages->toArray() as $userLanguage) { foreach ($event->getSite()->getLanguages() as $siteLanguage) { - foreach ($compareWith as $function) { + $compareWith = [ + (string)$siteLanguage->getLocale(), + $siteLanguage->getLocale()->getLanguageCode(), + ]; + foreach ($compareWith as $value) { $config = $siteLanguage->toArray(); if ($siteLanguage->enabled() && ($config['excludeFromLanguageDetection'] ?? false) !== true - && (string)$userLanguage === $this->normalizer->normalize((string)$siteLanguage->{$function}()) + && (string)$userLanguage === $this->normalizer->normalize($value) ) { $event->setSelectedLanguage($siteLanguage);