Compiles a list of language keys for which localizations have been loaded.

@return string[] a list of language keys (may be empty)
188393
private function getAvailableLanguages()
    {
        if ($this->availableLanguages === null) {
            $this->availableLanguages = [];

            if (!empty($this->LLkey)) {
                $this->availableLanguages[] = $this->LLkey;
            }
            // The key for English is "default", not "en".
            $this->availableLanguages = str_replace(
                'en',
                'default',
                $this->availableLanguages
            );
            // Remove duplicates in case the default language is the same as the fall-back language.
            $this->availableLanguages = array_unique($this->availableLanguages);

            // Now check that we only keep languages for which we have
            // translations.
            foreach ($this->availableLanguages as $index => $code) {
                if (!isset($this->LOCAL_LANG[$code])) {
                    unset($this->availableLanguages[$index]);
                }
            }
        }

        return $this->availableLanguages;
    }
219638
public static function getAvailableLocalesInfo()
    {
        $languages = [];
        foreach (static::getAvailableLocales() as $id) {
            $languages[$id] = new Language($id);
        }

        return $languages;
    }
955428
public function getAllLocalizations()
    {
        $localizations = [];
        foreach ($this->getLocalizations() as $child) {
            $localizations[] = $child;
            $localizations = array_merge($localizations, $child->getAllLocalizations());
        }

        return $localizations;
    }
112565
public function getLangDirs()
    {
        if (static::$cache_lang_dirs) {
            return static::$cache_lang_dirs;
        }
        $paths = [];

        // Search sorted modules (receives absolute paths)
        foreach ($this->getSortedModules() as $module => $path) {
            $langPath = "{$path}/lang/";
            if (is_dir($langPath)) {
                $paths[] = $langPath;
            }
        }

        // Search theme dirs (receives relative paths)
        $locator = ThemeResourceLoader::inst();
        foreach (SSViewer::get_themes() as $theme) {
            if ($locator->getSet($theme)) {
                continue;
            }
            $path = $locator->getPath($theme);
            $langPath = BASE_PATH . "/{$path}/lang/";
            if (is_dir($langPath)) {
                $paths[] = $langPath;
            }
        }

        static::$cache_lang_dirs = $paths;
        return $paths;
    }
801469
public function getTranslations(): array
    {
        // Get english name
        $name = [
            'eng' => [
                'common' => $this->getName(),
                'official' => $this->getOfficialName(),
            ],
        ];

        // Get native names
        $natives = $this->getNativeNames() ?: [];

        // Get other translations
        $file = __DIR__.'/../resources/translations/'.mb_strtolower($this->getIsoAlpha2()).'.json';
        $translations = file_exists($file) ? json_decode(file_get_contents($file), true) : [];

        // Merge all names together
        $result = array_merge($translations, $natives, $name);

        // Sort alphabetically
        ksort($result);

        return $result;
    }
1033581
public function getLanguageCodesList()
    {
        $languages = array();
        foreach ($this->getStores() as $store) {
            $languages[] = $store->getLanguageCode();
        }
        return array_unique($languages);
    }
538121
protected function getLocales()
    {
        return \localizer\locales()->reduce(function ($ids, $locale) {
            $ids[] = $locale->id();

            return $ids;
        }, []);
    }
704620
private function getLanguages()
    {
        $directories = glob($this->basePath.'/*', GLOB_ONLYDIR);

        $languages = array_map(function ($dir) {
            $name = basename($dir);

            return in_array($name, $this->excluded, true) ? null : $name;
        }, $directories);

        return array_filter($languages);
    }
367217
public function getLanguages()
    {
        // Cache by locale
        $locale = i18n::get_locale();
        if (!empty(static::$cache_languages[$locale])) {
            return static::$cache_languages[$locale];
        }

        // Localise all languages
        $languages = $this->config()->get('languages');
        $localised = [];
        foreach ($languages as $code => $default) {
            $localised[$code] = $this->languageName($code);
        }

        // Save cache
        static::$cache_languages[$locale] = $localised;
        return $localised;
    }
1187204
public function getUsedLanguages() {
		$alllanguages = $this->getAllLanguages();
		
		$usedlanguages = array();
		
		foreach ($alllanguages as $code=>$lang) {
			// check if lang folder and default file exists
			$langfile = $this->localespath.$code.'/default.txt';
			
			if (file_exists($langfile)) {
				$usedlanguages[$code] = $lang;
			}
		}
		
		return $usedlanguages;
	}
1021056
public function loadLanguages()
    {
        $languages = $this->languageHandler->loadAll();

        $returnArray = array();
        foreach ($languages as $language) {
            $returnArray[] = $this->buildDomainObject($language);
        }

        return $returnArray;
    }
181640
public function toArray()
	{
		$list = parent::toArray();

		$list['locale.language.id'] = $this->getId();
		$list['locale.language.code'] = $this->getCode();
		$list['locale.language.label'] = $this->getLabel();
		$list['locale.language.status'] = $this->getStatus();

		return $list;
	}
895256
public function fetchAll()
    {
        if (static::$languages === null) {
            static::$languages = $this->driver()->fetchAll();

            static::$languages = array_map(function ($language) {
                return new Locale($language);
            }, static::$languages);
        }

        return static::$languages;
    }
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;
    }
923469
private function recursionConfigOptions(): array
    {
        return [
            0                         => I18N::translate('none'),
            1                         => I18N::number(1),
            2                         => I18N::number(2),
            3                         => I18N::number(3),
            self::UNLIMITED_RECURSION => I18N::translate('unlimited'),
        ];
    }
396735
public function getAllLanguages() {
		
		if (is_array($this->alllanguages)) {
			return $this->alllanguages;
		}
		
		// find languages file in a locales path
		$langfile = $this->localespath.'languages.txt';

		if (!file_exists($langfile)) {
			// if no in locales then use default from this package
			$langfile = dirname(__FILE__).'/languages.txt';
		}

		if (!file_exists($langfile)) {
			// if not found then show error or return empty array
			if ($this->errorondatamissed) {
				throw new \Exception('No languages file found');
			}
			return array();
		}
		
		// load a file
		$list = @file_get_contents($langfile);
		
		if (!$list) {
			// if somethign went wrong throw error or return empty array
			if ($this->errorondatamissed) {
				throw new \Exception('Can not load languages list');
			}
			return array();
		}
		
		$languages = array();
		
		foreach (preg_split('!\\r?\\n!',$list) as $line) {
			
			list ($code,$name) = explode('=',$line);
			
			$code = trim($code);
			$name = trim($name);
			
			if ($code == '' || $name == '') {
				continue;
			}
			
			$origname = $name;
			$tags = array();
			
			$splitsettings = explode(':',$name,3);
			
			if (count($splitsettings) > 1) {
				$name = $splitsettings[0];
				$origname = $splitsettings[1];
				
				if (isset($splitsettings[2]) && $splitsettings[2] != '') {
					$tags = explode(',',$splitsettings[2]);
				}
			}
			
			$flagfile = $this->localespath.'flags/small/'.$code.'.png';
			
			$hasflag = file_exists($flagfile);
			
			$languages[$code] = array(
				'code'=>$code,
				'name'=>$name,
				'origname'=>$origname,
				'hasflag'=>$hasflag,
				'tags' => $tags
				);
		}
		return $languages;
	}
685229
public function loadAll()
    {
        $languages = $this->cache->get('ez-language-list');
        if ($languages === null) {
            $languages = $this->innerHandler->loadAll();
            $this->storeCache($languages, 'ez-language-list');
        }

        return $languages;
    }