Get the availables locales for the current installation (from installed extensions).
@return string[] the list of all locales supported by the app (even though a locale is used in only one extension).
332591
public static function getAvailableLanguages(){
        $languages = array();
        foreach(common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension){
           $localesDir = $extension->getDir() . 'locales/';
           foreach(glob($localesDir . '*') as  $file){
                if(is_dir($file) && file_exists($file . '/messages.po')){
                    $lang = basename($file);
                    if(!in_array($lang, $languages)){
                        $languages[] = $lang;
                    }
                }
           }
        } 
        return $languages;
    }
1006693
public function getAvailableLanguages()
    {
        $translationSiteAccesses = $this->configResolver->getParameter('translation_siteaccesses');
        $relatedSiteAccesses = $translationSiteAccesses ?: $this->configResolver->getParameter('related_siteaccesses');
        $availableLanguages = array();
        $currentLanguages = $this->configResolver->getParameter('languages');
        $availableLanguages[] = array_shift($currentLanguages);

        foreach ($relatedSiteAccesses as $sa) {
            $languages = $this->configResolver->getParameter('languages', null, $sa);
            $availableLanguages[] = array_shift($languages);
        }

        sort($availableLanguages);

        return array_unique($availableLanguages);
    }
1053134
public function enabledLocales()
    {
        $locales = [];
        foreach (locales() as $locale) {
            if (config('typicms.'.$locale.'.status')) {
                $locales[] = $locale;
            }
        }

        return $locales;
    }
1283487
public function getLocales()
    {
        $this->start();
        try {
            $this->getUserControl()->checkRateLimit();
            $this->getUserControl()->checkGenericAccess(__FUNCTION__);
            $locales = $this->app->make(LocaleRepository::class)->getApprovedLocales();
            $result = $this->buildJsonResponse($this->localesToArray($locales));
        } catch (Exception $x) {
            $result = $this->buildErrorResponse($x);
        } catch (Throwable $x) {
            $result = $this->buildErrorResponse($x);
        }

        return $this->finish($result);
    }
1181620
public Locale[] getAvailableLocales() {
        // TODO make this wrap getAvailableULocales later
        Set<String> visIDs = getVisibleIDs();
        Locale[] locales = new Locale[visIDs.size()];
        int n = 0;
        for (String id : visIDs) {
            Locale loc = LocaleUtility.getLocaleFromName(id);
            locales[n++] = loc;
        }
        return locales;
    }
219638
public static function getAvailableLocalesInfo()
    {
        $languages = [];
        foreach (static::getAvailableLocales() as $id) {
            $languages[$id] = new Language($id);
        }

        return $languages;
    }
226091
public function getAvailableLangs(): array
    {
        $langs = ['en'];
        $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true);
        foreach ($scan as $row) {
            $langs[] = trim($row, '/');
        }
        return $langs;
    }
282750
protected function getLangFiles()
    {
        if (static::$cache_lang_files) {
            return static::$cache_lang_files;
        }

        $locales = [];
        foreach ($this->getLangDirs() as $langPath) {
            $langFiles = scandir($langPath);
            foreach ($langFiles as $langFile) {
                $locale = pathinfo($langFile, PATHINFO_FILENAME);
                $ext = pathinfo($langFile, PATHINFO_EXTENSION);
                if ($locale && $ext === 'yml') {
                    $locales[$locale] = $locale;
                }
            }
        }
        ksort($locales);
        static::$cache_lang_files = $locales;
        return $locales;
    }
1029902
public function getSiblingLocales()
    {
        $domain = $this->getDomain();
        $locales = $domain
            ? $domain->getLocales()
            : Locale::getCached();
        return $locales;
    }
706384
public function getDisplayLocales()
    {
        $locales = array();

        foreach ($this->allowedLocales as $locale) {
            $locales[$locale] = \Locale::getDisplayName($locale);
        }

        return $locales;
    }
840507
public static List<ViewLocale> getAvailableViewLocales() {
		List<String> locales = readAvailableLocales();

		List<ViewLocale> localesUI = new ArrayList<>();
		if (!locales.isEmpty()) {
			for (String locale : locales) {
				localesUI.add(new ViewLocale(locale, getLocalDisplayName(locale)));
			}

			Collections.sort(localesUI, new Comparator<ViewLocale>() {

				@Override
				public int compare(ViewLocale o1, ViewLocale o2) {
					return o1.toString().compareTo(o2.toString());
				}
			});
		}

		// Always put English at the top
		localesUI.add(0, new ViewLocale(DEFAULT_LOCALE, getLocalDisplayName(DEFAULT_LOCALE)));

		return localesUI;
	}
559131
public function getLocaleOptions()
    {
        $localeOptions = [
            'ar'    => [Lang::get('system::lang.locale.ar'),    'flag-sa'],
            'be'    => [Lang::get('system::lang.locale.be'),    'flag-by'],
            'bg'    => [Lang::get('system::lang.locale.bg'),    'flag-bg'],
            'ca'    => [Lang::get('system::lang.locale.ca'),    'flag-es-ct'],
            'cs'    => [Lang::get('system::lang.locale.cs'),    'flag-cz'],
            'da'    => [Lang::get('system::lang.locale.da'),    'flag-dk'],
            'de'    => [Lang::get('system::lang.locale.de'),    'flag-de'],
            'el'    => [Lang::get('system::lang.locale.el'),    'flag-gr'],
            'en'    => [Lang::get('system::lang.locale.en'),    'flag-us'],
            'en-au' => [Lang::get('system::lang.locale.en-au'), 'flag-au'],
            'en-ca' => [Lang::get('system::lang.locale.en-ca'), 'flag-ca'],
            'en-gb' => [Lang::get('system::lang.locale.en-gb'), 'flag-gb'],
            'es'    => [Lang::get('system::lang.locale.es'),    'flag-es'],
            'es-ar' => [Lang::get('system::lang.locale.es-ar'), 'flag-ar'],
            'et'    => [Lang::get('system::lang.locale.et'),    'flag-ee'],
            'fa'    => [Lang::get('system::lang.locale.fa'),    'flag-ir'],
            'fi'    => [Lang::get('system::lang.locale.fi'),    'flag-fi'],
            'fr'    => [Lang::get('system::lang.locale.fr'),    'flag-fr'],
            'fr-ca' => [Lang::get('system::lang.locale.fr-ca'), 'flag-ca'],
            'hu'    => [Lang::get('system::lang.locale.hu'),    'flag-hu'],
            'id'    => [Lang::get('system::lang.locale.id'),    'flag-id'],
            'it'    => [Lang::get('system::lang.locale.it'),    'flag-it'],
            'ja'    => [Lang::get('system::lang.locale.ja'),    'flag-jp'],
            'kr'    => [Lang::get('system::lang.locale.kr'),    'flag-kr'],
            'lt'    => [Lang::get('system::lang.locale.lt'),    'flag-lt'],
            'lv'    => [Lang::get('system::lang.locale.lv'),    'flag-lv'],
            'nb-no' => [Lang::get('system::lang.locale.nb-no'), 'flag-no'],
            'nl'    => [Lang::get('system::lang.locale.nl'),    'flag-nl'],
            'pl'    => [Lang::get('system::lang.locale.pl'),    'flag-pl'],
            'pt-br' => [Lang::get('system::lang.locale.pt-br'), 'flag-br'],
            'pt-pt' => [Lang::get('system::lang.locale.pt-pt'), 'flag-pt'],
            'ro'    => [Lang::get('system::lang.locale.ro'),    'flag-ro'],
            'ru'    => [Lang::get('system::lang.locale.ru'),    'flag-ru'],
            'sk'    => [Lang::get('system::lang.locale.sk'),    'flag-sk'],
            'sv'    => [Lang::get('system::lang.locale.sv'),    'flag-se'],
            'tr'    => [Lang::get('system::lang.locale.tr'),    'flag-tr'],
            'uk'    => [Lang::get('system::lang.locale.uk'),    'flag-ua'],
            'vn'    => [Lang::get('system::lang.locale.vn'),    'flag-vn'],
            'zh-cn' => [Lang::get('system::lang.locale.zh-cn'), 'flag-cn'],
            'zh-tw' => [Lang::get('system::lang.locale.zh-tw'), 'flag-tw'],
        ];

        $locales = Config::get('app.localeOptions', $localeOptions);

        // Sort locales alphabetically
        asort($locales);

        return $locales;
    }
16781
public function getAll()
    {
        if (!$this->getResource()) {
            return [];
        }
        if ($this->useLocalResource) {
            return $this->localResource;
        }

        // If we're attempting to use a global resource but it doesn't exist, we've got a problem.
        if (!isset($GLOBALS[$this->getResource()])) {
            throw new \Parable\GetSet\Exception(
                "Attempting to use global resource '{$this->getResource()}' but resource not available."
            );
        }

        return $GLOBALS[$this->getResource()];
    }
770992
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @RequiresPermissions(I18nPermissions.LOCALE_READ)
    public Response getAvailableLocales() {
        List<LocaleRepresentation> availableLocales = localeFinder.findAvailableLocales();
        if (!availableLocales.isEmpty()) {
            return Response.ok(availableLocales).build();
        }
        return Response.noContent().build();
    }
735955
private function getAvailableLocales()
    {
        if (empty($this->availableLocales)) {
            // Open the pages directory.
            $pagesDirectory = opendir('../data/pages/');
            while ($directory = readdir($pagesDirectory)) {
                if (($directory != '.') && ($directory != '..')) {
                    $this->availableLocales[] = $directory;
                }
            }
            closedir($pagesDirectory);
        }

        return $this->availableLocales;
    }
629057
public static Set<String> getAvailableLocaleSuffixes() {

		Set<String> availableLocaleSuffixes = new HashSet<>();
		Locale[] availableLocales = Locale.getAvailableLocales();
		for (Locale locale : availableLocales) {
			StringBuilder sb = new StringBuilder();
			if (locale != null) {

				String language = locale.getLanguage();
				String country = locale.getCountry();
				String variant = locale.getVariant();

				if (StringUtils.isNotEmpty(variant)) {
					sb.append(language).append('_').append(country).append('_').append(variant);
				} else if (StringUtils.isNotEmpty(country)) {
					sb.append(language).append('_').append(country);
				} else {
					sb.append(language);
				}
			}
			availableLocaleSuffixes.add(sb.toString());
		}
		return availableLocaleSuffixes;
	}
33707
private function setupLocales(): array
    {
        return app(ModuleService::class)
            ->setupLanguages()
            ->map(static function (ModuleLanguageInterface $module): LocaleInterface {
                return $module->locale();
            })
            ->all();
    }