Get available locales

@param string|null|true $domain If provided, locales for the given domain will be returned.
If true, then the current state domain will be used (if in domain mode).
@return ArrayList
153
public static function getLocales($domain = null)
    {
        // Optionally filter by domain
        $domainObj = Domain::getByDomain($domain);
        if ($domainObj) {
            return $domainObj->getLocales();
        }

        return Locale::getCached();
    }
895436
public function getIdByDomain($domain)
    {
        return $this->cache->get('appDomain' . $domain, 86400, function () use ($domain) {
            $app = wei()->appRecord()->select('name')->fetch(['domain' => $domain]);

            return $app ? $app['name'] : false;
        });
    }
737218
private function getLanguages($forcedLanguage = null, $fallbackLanguage = null)
    {
        if ($forcedLanguage !== null) {
            $languages = array($forcedLanguage);
        } else {
            $languages = $this->configResolver->getParameter('languages');
        }

        // Always add $fallbackLanguage, even if null, as last entry so that we can fallback to
        // main/initial language if domain supports it.
        $languages[] = $fallbackLanguage;

        return $languages;
    }
1046852
protected function mx_query($domain)
        {
            $hosts = array();
            $weight = array();
            if (function_exists('getmxrr')) {
                getmxrr($domain, $hosts, $weight);
            } else {
                $this->getmxrr($domain, $hosts, $weight);
            }
            return array($hosts, $weight);
        }
979343
public function getRepositories(
        array $domains = [],
        array $languages = []
    ) : array {
        $repositories = array_filter(
            $this->repositories,
            function (Repository $repository) use ($domains) {
                return
                    empty($domains) ||
                    in_array($repository->getDomain(), $domains);
            }
        );

        return array_filter(
            $repositories,
            function (Repository $repository) use ($languages) {
                return
                    empty($languages) ||
                    in_array($repository->getLanguage(), $languages);
            }
        );
    }
733210
public function retrieve($domain)
	{
		if (!($messages = Monster::eat($this->key($domain))))
		{
			$messages = array();
		}

		if (count($messages))
		{
			$this->clear($domain);
		}

		return $messages;
	}
741162
public static function getStaticLanguageStrings( string $locale = 'en_US', string $version = null ) : array
	{
		$url = self::getStaticDataFileUrl(self::STATIC_LANGUAGESTRINGS, null, $locale, $version);
		return self::loadStaticData($url);
	}
1257790
public function domain($domain = null)
    {
        if (func_num_args() === 0) {
            return $this->_data['domain'];
        }
        return $this->_data['domain'] = $domain === null ?  $domain : (string) $domain;
    }
514714
public function getAll( $domain )
	{
		$messages = [];

		foreach( $this->getTranslations( $domain ) as $object ) {
			$messages = $messages + $object->all();
		}

		return $messages;
	}
428229
protected function initCatalogsForManyLocales($locales, $domain) {
		foreach ($locales as $locale) {
			$this->initCatalogsForSingleLocale($locale, $domain);
		}
	}
1265289
protected function get(string &$locale, string $domain, string $string): string
    {
        if ($this->catalogueManager->get($locale)->has($domain, $string)) {
            return $this->catalogueManager->get($locale)->get($domain, $string);
        }

        $locale = $this->config->getFallbackLocale();

        if ($this->catalogueManager->get($locale)->has($domain, $string)) {
            return $this->catalogueManager->get($locale)->get($domain, $string);
        }

        // we can automatically register message
        if ($this->config->isAutoRegisterMessages()) {
            $this->catalogueManager->get($locale)->set($domain, $string, $string);
            $this->catalogueManager->save($locale);
        }

        //Unable to find translation
        return $string;
    }
427528
public function getAllByLocaleAndDomain($locale, $domain)
    {
        return $this->createQueryBuilder('tu')
            ->select('tu, te')
            ->leftJoin('tu.translations', 'te')
            ->where('tu.domain = :domain')
            ->andWhere('te.locale = :locale')
            ->setParameter('domain', $domain)
            ->setParameter('locale', $locale)
            ->getQuery()
            ->getArrayResult();
    }
613031
static public function getSecondDomain($domain=null)
	{
	    $domain = !empty($domain) ? $domain : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
	    $n = preg_match('/([^.]*\.)?([^.]*\.)?\w+\.\w+$/', $domain, $matches);
	    return $domain && isset($matches[2]) ? $matches[2] : (isset($matches[1]) ? $matches[1] : '');
	}
1034852
public function getDomainInfo( $domain ) {
		$domain = $this->normalizeDomain( $domain );
		// Check cache and custom-registered domains
		if ( !isset( $this->domainInfos[ $domain ] ) ) {
			// Default to local domain
			$dir = $this->localBaseDir . '/language/messages/' . $domain;
			if ( !is_dir( $dir ) ) {
				// Domain does not exist
				return false;
			}
			$this->domainInfos[ $domain ] = [
				'dir' => $dir,
			];
		}
		return $this->domainInfos[ $domain ];
	}
485772
protected function getTranslation($domain, $context, $original)
    {
        return $this->dictionary[$domain][$context][$original] ?? false;
    }
754100
public function findForLocalesAndDomains(array $locales, array $domains)
    {
        $builder = $this->createQueryBuilder('f');

        if (count($locales) > 0) {
            $builder->andWhere($builder->expr()->in('f.locale', $locales));
        }

        if (count($domains) > 0) {
            $builder->andWhere($builder->expr()->in('f.domain', $domains));
        }

        return $builder->getQuery()->getResult();
    }
96945
public function getDomainConfiguration($domain = null)
    {
        if ($domain && isset($this->domains[$domain])) {
            return $this->domains[$domain];
        } elseif ($domain) {
            throw new InvalidArgumentException(sprintf('Domain "%s" not found.', $domain));
        } else {
            return $this->domains;
        }
    }