diff --git a/src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php b/src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php index b3b6943..5026016 100644 --- a/src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php +++ b/src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php @@ -38,15 +38,34 @@ public function expandStoreTransfersWithLocales(array $storeTransfers): array } $localeNamesGroupedByIdStore = $this->localeRepository->getLocaleNamesGroupedByIdStore($storeIds); + $indexedLocaleNamesGroupedByIdStore = $this->indexLocaleNamesByShortName($localeNamesGroupedByIdStore); $defaultLocaleNamesIndexedByIdStore = $this->localeRepository->getDefaultLocaleNamesIndexedByIdStore($storeIds); foreach ($storeTransfers as $storeTransfer) { $storeTransfer ->setDefaultLocaleIsoCode($defaultLocaleNamesIndexedByIdStore[$storeTransfer->getIdStoreOrFail()]) - ->setAvailableLocaleIsoCodes($localeNamesGroupedByIdStore[$storeTransfer->getIdStoreOrFail()] ?? []); + ->setAvailableLocaleIsoCodes($indexedLocaleNamesGroupedByIdStore[$storeTransfer->getIdStoreOrFail()] ?? []); } return $storeTransfers; } + + /** + * @param array> $localeNamesGroupedByIdStore + * + * @return array> + */ + protected function indexLocaleNamesByShortName(array $localeNamesGroupedByIdStore): array + { + $indexedLocaleNamesGroupedByIdStore = []; + foreach ($localeNamesGroupedByIdStore as $idStore => $localeNames) { + foreach ($localeNames as $localeName) { + [$locale, $region] = explode('_', $localeName); + $indexedLocaleNamesGroupedByIdStore[$idStore][$locale] = $localeName; + } + } + + return $indexedLocaleNamesGroupedByIdStore; + } }