protected function generateAvailableLocalesCollectionByScanningFilesystem()
    {
        $includePaths = array_keys(array_filter((array)$this->settings['scan']['includePaths']));
        if ($includePaths === []) {
            return;
        }
        $excludePattern = $this->getScanExcludePattern();

        /** @var FlowPackageInterface $activePackage */
        foreach ($this->packageManager->getFlowPackages() as $activePackage) {
            $packageResourcesPath = Files::getNormalizedPath($activePackage->getResourcesPath());

            if (!is_dir($packageResourcesPath)) {
                continue;
            }

            $directories = [];
            foreach ($includePaths as $path) {
                $scanPath = Files::concatenatePaths([$packageResourcesPath, $path]);
                if (is_dir($scanPath)) {
                    array_push($directories, Files::getNormalizedPath($scanPath));
                }
            }

            while ($directories !== []) {
                $currentDirectory = array_pop($directories);
                $relativeDirectory = '/' . str_replace($packageResourcesPath, '', $currentDirectory);
                if ($excludePattern !== '' && preg_match($excludePattern, $relativeDirectory) === 1) {
                    continue;
                }

                if (stripos($currentDirectory, '/Private/Translations/') !== false) {
                    $localeIdentifier = Utility::extractLocaleTagFromDirectory($currentDirectory);
                    if ($localeIdentifier !== false) {
                        $this->localeCollection->addLocale(new Locale($localeIdentifier));
                    }
                }
                if ($handle = opendir($currentDirectory)) {
                    while (false !== ($filename = readdir($handle))) {
                        if ($filename[0] === '.') {
                            continue;
                        }
                        $pathAndFilename = Files::concatenatePaths([$currentDirectory, $filename]);
                        if (is_dir($pathAndFilename)) {
                            array_push($directories, Files::getNormalizedPath($pathAndFilename));
                        } else {
                            $localeIdentifier = Utility::extractLocaleTagFromFilename($filename);
                            if ($localeIdentifier !== false) {
                                $this->localeCollection->addLocale(new Locale($localeIdentifier));
                            }
                        }
                    }
                    closedir($handle);
                }
            }
        }
    }
protected function generateAvailableLocalesCollectionByScanningFilesystem()
    {
        $includePaths = array_keys(array_filter((array)$this->settings['scan']['includePaths']));
        if ($includePaths === []) {
            return;
        }
        $excludePattern = $this->getScanExcludePattern();

        /** @var FlowPackageInterface $activePackage */
        foreach ($this->packageManager->getFlowPackages() as $activePackage) {
            $packageResourcesPath = Files::getNormalizedPath($activePackage->getResourcesPath());

            if (!is_dir($packageResourcesPath)) {
                continue;
            }

            $directories = [];
            foreach ($includePaths as $path) {
                $scanPath = Files::concatenatePaths([$packageResourcesPath, $path]);
                if (is_dir($scanPath)) {
                    array_push($directories, Files::getNormalizedPath($scanPath));
                }
            }

            while ($directories !== []) {
                $currentDirectory = array_pop($directories);
                $relativeDirectory = '/' . str_replace($packageResourcesPath, '', $currentDirectory);
                if ($excludePattern !== '' && preg_match($excludePattern, $relativeDirectory) === 1) {
                    continue;
                }

                if (stripos($currentDirectory, '/Private/Translations/') !== false) {
                    $localeIdentifier = Utility::extractLocaleTagFromDirectory($currentDirectory);
                    if ($localeIdentifier !== false) {
                        $this->localeCollection->addLocale(new Locale($localeIdentifier));
                    }
                }
                if ($handle = opendir($currentDirectory)) {
                    while (false !== ($filename = readdir($handle))) {
                        if ($filename[0] === '.') {
                            continue;
                        }
                        $pathAndFilename = Files::concatenatePaths([$currentDirectory, $filename]);
                        if (is_dir($pathAndFilename)) {
                            array_push($directories, Files::getNormalizedPath($pathAndFilename));
                        } else {
                            $localeIdentifier = Utility::extractLocaleTagFromFilename($filename);
                            if ($localeIdentifier !== false) {
                                $this->localeCollection->addLocale(new Locale($localeIdentifier));
                            }
                        }
                    }
                    closedir($handle);
                }
            }
        }
    }
protected function generateAvailableLocalesCollectionByScanningFilesystem ( ) { $ includePaths = array_keys ( array_filter ( ( array ) $ this -> settings [ 'scan' ] [ 'includePaths' ] ) ) ; if ( $ includePaths === [ ] ) { return ; } $ excludePattern = $ this -> getScanExcludePattern ( ) ; /** @var FlowPackageInterface $activePackage */ foreach ( $ this -> packageManager -> getFlowPackages ( ) as $ activePackage ) { $ packageResourcesPath = Files :: getNormalizedPath ( $ activePackage -> getResourcesPath ( ) ) ; if ( ! is_dir ( $ packageResourcesPath ) ) { continue ; } $ directories = [ ] ; foreach ( $ includePaths as $ path ) { $ scanPath = Files :: concatenatePaths ( [ $ packageResourcesPath , $ path ] ) ; if ( is_dir ( $ scanPath ) ) { array_push ( $ directories , Files :: getNormalizedPath ( $ scanPath ) ) ; } } while ( $ directories !== [ ] ) { $ currentDirectory = array_pop ( $ directories ) ; $ relativeDirectory = '/' . str_replace ( $ packageResourcesPath , '' , $ currentDirectory ) ; if ( $ excludePattern !== '' && preg_match ( $ excludePattern , $ relativeDirectory ) === 1 ) { continue ; } if ( stripos ( $ currentDirectory , '/Private/Translations/' ) !== false ) { $ localeIdentifier = Utility :: extractLocaleTagFromDirectory ( $ currentDirectory ) ; if ( $ localeIdentifier !== false ) { $ this -> localeCollection -> addLocale ( new Locale ( $ localeIdentifier ) ) ; } } if ( $ handle = opendir ( $ currentDirectory ) ) { while ( false !== ( $ filename = readdir ( $ handle ) ) ) { if ( $ filename [ 0 ] === '.' ) { continue ; } $ pathAndFilename = Files :: concatenatePaths ( [ $ currentDirectory , $ filename ] ) ; if ( is_dir ( $ pathAndFilename ) ) { array_push ( $ directories , Files :: getNormalizedPath ( $ pathAndFilename ) ) ; } else { $ localeIdentifier = Utility :: extractLocaleTagFromFilename ( $ filename ) ; if ( $ localeIdentifier !== false ) { $ this -> localeCollection -> addLocale ( new Locale ( $ localeIdentifier ) ) ; } } } closedir ( $ handle ) ; } } } }
Finds all Locale objects representing locales available in the
Flow installation. This is done by scanning all Private and Public
resource files of all active packages, in order to find localized files.

Localized files have a locale identifier added before their extension
(or at the end of filename, if no extension exists). For example, a
localized file for foobar.png, can be foobar.en.png, foobar.en_GB.png, etc.

Also, all folder names inside '/Private/Translations' are scanned for valid locales.

Just one localized resource file causes the corresponding locale to be
regarded as available (installed, supported).

Note: result of this method invocation is cached

@return void
Finds all Locale objects representing locales available in the Flow installation . This is done by scanning all Private and Public resource files of all active packages in order to find localized files .