Returns a list of known languages for an area

@param   string  $basePath  The basepath to use

@return  array  key/value pair with the language file and real name.

@since   1.0
19022
public static function getKnownLanguages($basePath = JPATH_ROOT)
	{
		$dir = self::getLanguagePath($basePath);
		$knownLanguages = self::parseLanguageFiles($dir);

		return $knownLanguages;
	}
704882
public function load($baseName) 
    {     
        $langFile = "{$this->dir}/{$this->locale}/{$baseName}.php";

        if (!is_file($langFile)) {
            return $this->langs;
        }
        
        $langs = include_once $langFile;
        if ($langs && is_array($langs)) {
            $this->langs = array_merge_recursive($this->langs, $langs);
        }
        
        return $this->langs;
    }
1261586
public static function listFilePaths ( $targetPath ) {
        if ( is_file($targetPath) === true ) {
            return array($targetPath);
        }

        if ( !is_dir($targetPath) || !($dh = opendir($targetPath)) ) {
            return array();
        }

        $fileList = array();
        while ( ($fileName = readdir($dh)) !== false ) {
            if ( $fileName === '.' || $fileName === '..' ) {
                continue;
            }

            $realPath = realpath($targetPath) . '/' . $fileName;

            if ( is_dir($realPath) === true ) {
                $fileList = array_merge($fileList, self::listFilePaths($realPath));
            } else {
                $fileList[] = $realPath;
            }
        }
        closedir($dh);
        sort($fileList);

        return $fileList;
    }
1308464
public function basePath(?string $basePath = null) {
        if ($basePath != null) {
            $this->basePath = $basePath;
        }
        return $this->basePath;
    }
1098011
public function getLanguageFiles(bool $useDefaultLocale = false)
    {
        $files = [];

        if ($useDefaultLocale) {
            $locale = $this->getDefaultLocale();
        } else {
            $locale = $this->getLocale();
        }

        $paths = $this->fileSystem->getFiles($this->getLanguagesPath() . DIRECTORY_SEPARATOR . $locale);

        foreach ($paths as $path) {
            $completeFileName = substr($path, strlen($this->getLanguagesPath()) + strlen($locale) + 2);

            $files[] = array_pad(explode(".", $completeFileName), 2, '.ext')[0];
        }

        return $files;
    }
899905
public function setBasePath($basePath)
    {
        $this['path.app'] = rtrim($basePath);

        foreach (['config', 'views', 'logs'] as $v) {
            $this['path.' . $v] = realpath(rtrim($basePath) . '/' . $v) . DIRECTORY_SEPARATOR;
        }

        $this['namespace.controller'] = '';

        return $this;
    }
175423
public function get_list_of_translations($returnall = false) {
        // Return all is ignored here - we need to know all langs in installer.
        $languages = array();
        // Get raw list of lang directories.
        $langdirs = get_list_of_plugins('install/lang');
        asort($langdirs);
        // Get some info from each lang.
        foreach ($langdirs as $lang) {
            if (file_exists($this->installroot . '/' . $lang . '/langconfig.php')) {
                $string = array();
                include($this->installroot . '/' . $lang . '/langconfig.php');
                if (!empty($string['thislanguage'])) {
                    $languages[$lang] = $string['thislanguage'] . ' (' . $lang . ')';
                }
            }
        }
        // Return array.
        return $languages;
    }
640657
protected function getGlobPaths($path)
    {
        $paths = [];
        $iterator = new \GlobIterator($path);

        foreach ($iterator as $fileInfo) {
            /* @var $fileInfo \SplFileInfo */
            $paths[] = $fileInfo->getPathname();
        }

        // validate
        if (count($paths) === 0) {
            throw new InvalidConfigurationException("coverage_clover XML file is not readable: ${path}");
        }

        return $paths;
    }
15869
protected function getLanguages(array $paths = [])
    {
        // Get language path
        $dir_lang = $this->getLangPath();

        // Only use the default locale
        if ($this->config('default_locale_only')) {
            return [
                $this->default_locale => "{$dir_lang}/{$this->default_locale}",
            ];
        }

        // Get all language paths
        foreach (glob("{$dir_lang}/*", GLOB_ONLYDIR) as $path) {
            $paths[basename($path)] = $path;
        }

        return $paths;
    }
1106557
public function language($extension, $basePath = PATH_CORE)
	{
		return App::get('language')->load(strtolower($extension), $basePath);
	}
490485
private function normalizeMetadata(array $metaData, string $basePath): array
    {
        if (empty($basePath)) {
            $basePath = '.';
        }

        if (empty($metaData['path'])) {
            $metaData['path'] = '.';
        }

        if (empty($metaData['type'])) {
            $metaData['type'] = 'dir';
        }

        if ($metaData['path'] == $basePath) {
            if ('file' == $metaData['type']) {
                $parts = explode('/', $metaData['path']);
                $metaData['path'] = array_pop($parts);
            } else {
                $metaData['path'] = '.';
            }
        } elseif ('.' != $basePath) {
            $metaData['path'] = substr($metaData['path'], strlen($basePath) + 1);
        }

        if (isset($metaData['size'])) {
            $metaData['size'] = $this->humanFileSize($metaData['size']);
        } else {
            $metaData['size'] = '';
        }

        return $metaData;
    }
477377
public function defaults($basePath = null)
    {
        $defaults = [];
        foreach ($this->_columns as $key => $value) {
            if ($basePath) {
                $fieldName = strpos($key, $basePath . '.') === 0 ? substr($key, strlen($basePath) + 1) : null;
            } else {
                $fieldName = $key;
            }
            if (!$fieldName || $fieldName === '*' || strpos($fieldName, '.') !== false) {
                continue;
            }
            if (isset($value['default'])) {
                $defaults[$fieldName] = $value['default'];
            }
        }
        return $defaults;
    }
18640
protected function createLanguageList($selected, $basePath = JPATH_ROOT)
	{
		$list = array();

		// Cache activation
		$langs = Language::getKnownLanguages($basePath);

		foreach ($langs as $lang => $metadata)
		{
			$option = array();

			$option['text'] = $metadata['name'];
			$option['value'] = $lang;

			if ($lang == $selected)
			{
				$option['selected'] = 'selected="selected"';
			}

			$list[] = $option;
		}

		return $list;
	}
672706
public static function within($listenerPath, $basePath)
    {
        return collect(static::getListenerEvents(
            (new Finder)->files()->in($listenerPath), $basePath
        ))->mapToDictionary(function ($event, $listener) {
            return [$event => $listener];
        })->all();
    }
1106914
public function getStorageBaseDirectory($basePath = null)
    {
        // Get base storage path configuration
        $storage = $this->get('storage');

        // Check if storage is relative to the application path or not
        $relative = $storage['path_is_relative'] ?: true;

        return ($relative ? $basePath . DIRECTORY_SEPARATOR : '') . $storage['base_dir'];
    }
225607
public function getImplementedLocales($path = '/../Resources/translations/')
    {
        $locales = [];
        $finder = $this->finder->files()->in(__DIR__.$path)->name('/platform\.[^.]*\.json/');

        foreach ($finder as $file) {
            $locale = str_replace(['platform.', '.json'], '', $file->getRelativePathname());
            $locales[$locale] = $locale;
        }

        return $locales;
    }
1070856
static function languageInfoFromPackageList( $packageNameList, $withLanguageNames = false )
    {
        $languageInfo = array();
        foreach( $packageNameList as $packageName )
        {
            $package = eZPackage::fetch( $packageName, false, false, false );
            if( is_object( $package ) )
            {
                $packageLanguageInfo = $package->languageInfo( $withLanguageNames );
                // merge arrays
                if( $withLanguageNames )
                {
                    // we have array like 'locale' => 'name'. can use array_merge
                    $languageInfo = array_merge( $languageInfo, $packageLanguageInfo );
                }
                else
                {
                    foreach( $packageLanguageInfo as $languageLocale )
                    {
                        if( !in_array( $languageLocale, $languageInfo ) )
                        {
                            $languageInfo[] = $languageLocale;
                        }
                    }
                }
            }
            else
            {
                eZDebug::writeWarning( "Unable to fetch package '$packageName'", __METHOD__ );
            }
        }

        return $languageInfo;
    }