src/Classes/ExportLocalizations.php
protected function findLanguageFiles($path)
    {
        // Loop through directories
        $dirIterator = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
        $recIterator = new \RecursiveIteratorIterator($dirIterator);

        // Fetch only php files - skip others
        $phpFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->phpRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $jsonFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->jsonRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $files = array_merge($phpFiles, $jsonFiles);

        // Sort array by filepath
        sort($files);

        // Remove full path from items
        array_walk($files, function (&$item) use ($path) {
            $item = str_replace($path, '', $item);
        });

        // Fetch non-vendor files from filtered php files
        $nonVendorFiles = array_filter($files, function ($file) {
            return strpos($file, $this->excludePath) === false && strpos($file, '.json') === false;
        });

        // Fetch vendor files from filtered php files
        $vendorFiles = array_filter(array_diff($files, $nonVendorFiles), function ($file) {
            return strpos($file, 'json') === false;
        });

        // Fetch .json files from filtered files
        $jsonFiles = array_filter($files, function ($file) {
            return strpos($file, '.json') !== false;
        });

        return [
            'lang'   => array_values($nonVendorFiles),
            'vendor' => array_values($vendorFiles),
            'json'   => array_values($jsonFiles),
        ];
    }
protected function findLanguageFiles($path)
    {
        // Loop through directories
        $dirIterator = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS);
        $recIterator = new \RecursiveIteratorIterator($dirIterator);

        // Fetch only php files - skip others
        $phpFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->phpRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $jsonFiles = array_values(
            array_map('current',
                iterator_to_array(
                    new \RegexIterator($recIterator, $this->jsonRegex, \RecursiveRegexIterator::GET_MATCH)
                )
            )
        );

        $files = array_merge($phpFiles, $jsonFiles);

        // Sort array by filepath
        sort($files);

        // Remove full path from items
        array_walk($files, function (&$item) use ($path) {
            $item = str_replace($path, '', $item);
        });

        // Fetch non-vendor files from filtered php files
        $nonVendorFiles = array_filter($files, function ($file) {
            return strpos($file, $this->excludePath) === false && strpos($file, '.json') === false;
        });

        // Fetch vendor files from filtered php files
        $vendorFiles = array_filter(array_diff($files, $nonVendorFiles), function ($file) {
            return strpos($file, 'json') === false;
        });

        // Fetch .json files from filtered files
        $jsonFiles = array_filter($files, function ($file) {
            return strpos($file, '.json') !== false;
        });

        return [
            'lang'   => array_values($nonVendorFiles),
            'vendor' => array_values($vendorFiles),
            'json'   => array_values($jsonFiles),
        ];
    }
protected function findLanguageFiles ( $ path ) { // Loop through directories $ dirIterator = new \ RecursiveDirectoryIterator ( $ path , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ recIterator = new \ RecursiveIteratorIterator ( $ dirIterator ) ; // Fetch only php files - skip others $ phpFiles = array_values ( array_map ( 'current' , iterator_to_array ( new \ RegexIterator ( $ recIterator , $ this -> phpRegex , \ RecursiveRegexIterator :: GET_MATCH ) ) ) ) ; $ jsonFiles = array_values ( array_map ( 'current' , iterator_to_array ( new \ RegexIterator ( $ recIterator , $ this -> jsonRegex , \ RecursiveRegexIterator :: GET_MATCH ) ) ) ) ; $ files = array_merge ( $ phpFiles , $ jsonFiles ) ; // Sort array by filepath sort ( $ files ) ; // Remove full path from items array_walk ( $ files , function ( & $ item ) use ( $ path ) { $ item = str_replace ( $ path , '' , $ item ) ; } ) ; // Fetch non-vendor files from filtered php files $ nonVendorFiles = array_filter ( $ files , function ( $ file ) { return strpos ( $ file , $ this -> excludePath ) === false && strpos ( $ file , '.json' ) === false ; } ) ; // Fetch vendor files from filtered php files $ vendorFiles = array_filter ( array_diff ( $ files , $ nonVendorFiles ) , function ( $ file ) { return strpos ( $ file , 'json' ) === false ; } ) ; // Fetch .json files from filtered files $ jsonFiles = array_filter ( $ files , function ( $ file ) { return strpos ( $ file , '.json' ) !== false ; } ) ; return [ 'lang' => array_values ( $ nonVendorFiles ) , 'vendor' => array_values ( $ vendorFiles ) , 'json' => array_values ( $ jsonFiles ) , ] ; }
Find available language files and parse them to array.

@param string $path

@return array
Find available language files and parse them to array .