Filter locale collection.

@param  array  $supportedLocales

@return \Arcanedev\Localization\Entities\LocaleCollection
429184
private function filterLocales(array $supportedLocales)
    {
        return $this->locales->filter(function(Locale $locale) use ($supportedLocales) {
            return in_array($locale->key(), $supportedLocales);
        });
    }
407185
protected function filterByProperty(array $locales, $property)
    {
        $filtered = [];

        foreach ($locales as $locale) {
            if ( ! empty($locale->$property) && ! in_array($locale->$property, $filtered)) {
                $filtered[] = $locale->$property;
            }
        }

        return $filtered;
    }
370993
protected function generateAvailableLocalesCollectionFromSettings()
    {
        foreach ($this->settings['availableLocales'] as $localeIdentifier) {
            $this->localeCollection->addLocale(new Locale($localeIdentifier));
        }
    }
1069418
public function findByLocale(string $locale): ICollection
	{
		$builder = $this->builder()
			->innerJoin('_pages', '[_locales]', 'l', '_pages.localeId = l.id')
			->andWhere('[url] IS NOT NULL')
			->andWhere('[visible] = %i', 1)
			->andWhere('[l.name] = %s', $locale);
		return $this->toCollection($builder);
	}
365665
private function filterByLocalMajorVersion(array $versions)
    {
        list($localMajorVersion, ) = explode('.', $this->localVersion, 2);

        return array_filter($versions, function ($version) use ($localMajorVersion) {
            list($majorVersion, ) = explode('.', $version, 2);
            return $majorVersion === $localMajorVersion;
        });
    }
511573
public static function getAllCountriesForLocale($locale)
    {
        $dataDir = __DIR__ . DIRECTORY_SEPARATOR . static::$dataDir;
        $regionList = require $dataDir . '_list.php';

        if (!isset($regionList[$locale])) {
            throw new \RuntimeException("Locale is not supported");
        }

        /*
         * Loop through each part of the $locale, and load data for that locale
         *
         * E.g zh-Hans-HK will look for zh-Hanks-HK, zh-Hanks, then finally zh
         */
        $fallbackParts = explode('-', str_replace('_', '-', $locale));
        $filesToSearch = array();

        $i = count($fallbackParts);
        while ($i > 0) {
            $searchLocale = strtolower(implode('-', $fallbackParts));

            if (isset($regionList[$searchLocale])) {
                $filesToSearch[] = $searchLocale;
            }

            array_pop($fallbackParts);
            $i--;
        }

        /*
         * Load data files, and load the region (if it exists) from it
         */

        $returnData = array();

        foreach ($filesToSearch as $fileToSearch) {
            // Load data file
            $data = require $dataDir . $fileToSearch . '.php';

            $returnData += $data;
        }

        ksort($returnData);

        return $returnData;
    }
1126831
public function removeLocalesCacheFiles(array $locales)
    {
        foreach ($locales as $locale) {
            $this->removeCacheFile($locale);
        }

        // also remove database.resources.php cache file
        $file = sprintf('%s/database.resources.php', $this->options['cache_dir']);
        if (file_exists($file)) {
            $this->invalidateSystemCacheForFile($file);
            unlink($file);
        }

        $metadata = $file.'.meta';
        if (file_exists($metadata)) {
            $this->invalidateSystemCacheForFile($metadata);
            unlink($metadata);
        }
    }
4844
private function findAvailableParentLocalization(array $availableLocales, Localization $localization)
    {
        do {
            if (in_array($localization->getLocale(), $availableLocales)) {
                return $localization;
            }

            // try to load parent and stop if there is no parent
            $localization = $localization->getParent();
        } while (null != $localization);

        return;
    }
1171408
public function findAllByLocale($locale, $filter = array())
    {
        if (empty($filter)) {
            $order = $this->orderRepository->findAllByLocale($locale);
        } else {
            $order = $this->orderRepository->findByLocaleAndFilter($locale, $filter);
        }

        if ($order) {
            array_walk(
                $order,
                function (&$order) use ($locale) {
                    $order = $this->orderFactory->createApiEntity($order, $locale);
                    $this->updateApiEntity($order, $locale);
                }
            );
        }

        return $order;
    }
895650
private function filterUntranslatedBlocks(iterable $blocks, ?array $locales, bool $useMainLocale): Generator
    {
        foreach ($blocks as $block) {
            try {
                yield $this->mapper->mapBlock($block, $locales, $useMainLocale);
            } catch (NotFoundException $e) {
                // Block does not have the translation, skip it
            }
        }
    }
996414
public function getSupportedLocales()
    {
        $return = [];
        $process = new Process(['locale', '-a']);
        $process->run();
        $installedLocales = explode(PHP_EOL, trim($process->getOutput()));
        foreach ($this->supportedLocales as $supportedLocale) {
            if (in_array($supportedLocale, $installedLocales)
                || in_array($supportedLocale.'.utf8', $installedLocales)
            ) {
                $return[] = new Locale($supportedLocale);
            }
        }

        return $return;
    }
164931
public function getSupportedLanguages(): array
    {
        if (null === $this->supportedLanguages) {
            $this->supportedLanguages = [];
            $files = new \DirectoryIterator($this->getDictionaryFolder());
            foreach ($files as $file) {
                if ($file->getExtension() === 'aff') {
                    $this->supportedLanguages[] = $file->getBasename('.aff');
                }
            }
            sort($this->supportedLanguages);
        }

        return $this->supportedLanguages;
    }
614497
public static Map<String, String> getSupportedLocales() {
		Map<String, String> locales = new HashMap<String, String>();
		for (String localeName : LocaleInfo.getAvailableLocaleNames()) {
			String displayName = LocaleInfo.getLocaleNativeDisplayName(localeName);
			locales.put(localeName, displayName);
		}
		return locales;
	}
950147
public function getLocales()
    {
        $entities = [];
        if ($this->entity->getLocales()) {
            foreach ($this->entity->getLocales() as $locale) {
                $entities[] = new ContactLocale($locale);
            }
        }

        return $entities;
    }
121506
public static function activeLocales(): array
    {
        $locales = app(ModuleService::class)
            ->findByInterface(ModuleLanguageInterface::class, false, true)
            ->map(static function (ModuleLanguageInterface $module): LocaleInterface {
                return $module->locale();
            });

        if ($locales->isEmpty()) {
            return [new LocaleEnUs()];
        }

        return $locales->all();
    }
1370984
public function getLocales()
    {
        $locales = $this->serviceManager->get('playgroundcore_locale_service')->getLocaleMapper()->findAll();
        $localesForm = array();
        foreach ($locales as $key => $locale) {
            $localesForm[$locale->getLocale()] = $locale->getName(). " (".$locale->getLocale().")";
        }
        return $localesForm;
    }
645798
protected function _getPossibleLocales() {
        $bootstrap = $this->getBootstrap();
        $bootstrap->bootstrap('FrontController');
        $frontController = $bootstrap->getContainer()->frontcontroller;
        $locales = $frontController->getParam('locales');
        return $locales;
    }