Returns all locale string of the given domain.

@param string $domain Translation domain
@return array Associative list with original string as key and associative list with index => translation as value
514714
public function getAll( $domain )
	{
		$messages = [];

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

		return $messages;
	}
1257790
public function domain($domain = null)
    {
        if (func_num_args() === 0) {
            return $this->_data['domain'];
        }
        return $this->_data['domain'] = $domain === null ?  $domain : (string) $domain;
    }
1224721
public function textDomain( $textDomain = self::DEFAULT_TEXT_DOMAIN,
                                $locale     = null )
    {
        $translator = $this->getTranslator();
        $locale     = $locale ?: $translator->getLocale();

        if ( ! isset( $translator->myMessages[$textDomain][$locale] ) )
        {
            $translator->loadMyMessages( $textDomain, $locale );
        }

        if ( ! isset( $translator->messages[$textDomain][$locale] ) )
        {
            $translator->loadMessages( $textDomain, $locale );
        }

        $my     = $translator->myMessages[$textDomain][$locale];
        $global = $translator->messages[$textDomain][$locale];

        if ( $my instanceof TextDomain )
        {
            $my = $my->getArrayCopy();
        }
        else if ( empty( $my ) )
        {
            $my = array();
        }

        if ( $global instanceof TextDomain )
        {
            $global = $global->getArrayCopy();
        }
        else if ( empty( $global ) )
        {
            $global = array();
        }

        return array_replace( $global, $my );
    }
88005
private function getRootDomain($domain)
    {
        $domainParts = explode('.', $domain);
        $count       = count($domainParts);

        return $count > 1
            ? $domainParts[$count - 2].'.'.$domainParts[$count - 1]
            : $domainParts[0];
    }
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();
    }
1296448
public function gettext($attrib, $domain = null)
    {
        // load localization files if not done yet
        if (empty($this->texts)) {
            $this->load_language();
        }

        // extract attributes
        if (is_string($attrib)) {
            $attrib = array('name' => $attrib);
        }

        $name = (string) $attrib['name'];

        // attrib contain text values: use them from now
        if (($setval = $attrib[strtolower($_SESSION['language'])]) || ($setval = $attrib['en_us'])) {
            $this->texts[$name] = $setval;
        }

        // check for text with domain
        if ($domain && ($text = $this->texts[$domain.'.'.$name])) {
        }
        // text does not exist
        else if (!($text = $this->texts[$name])) {
            return "[$name]";
        }

        // replace vars in text
        if (is_array($attrib['vars'])) {
            foreach ($attrib['vars'] as $var_key => $var_value) {
                $text = str_replace($var_key[0] != '$' ? '$'.$var_key : $var_key, $var_value, $text);
            }
        }

        // replace \n with real line break
        $text = strtr($text, array('\n' => "\n"));

        // case folding
        if (($attrib['uppercase'] && strtolower($attrib['uppercase']) == 'first') || $attrib['ucfirst']) {
            $case_mode = MB_CASE_TITLE;
        }
        else if ($attrib['uppercase']) {
            $case_mode = MB_CASE_UPPER;
        }
        else if ($attrib['lowercase']) {
            $case_mode = MB_CASE_LOWER;
        }

        if (isset($case_mode)) {
            $text = mb_convert_case($text, $case_mode);
        }

        return $text;
    }
80649
public static function getByDomain($domain)
    {
        // Map true -> actual domain
        if ($domain === true) {
            $state = FluentState::singleton();
            $domain = $state->getIsDomainMode() ? $state->getDomain() : null;
        }

        // No domain found
        if (!$domain) {
            return null;
        }

        if ($domain instanceof Domain) {
            return $domain;
        }

        // Get filtered domain
        return static::getCached()
            ->filter('Domain', $domain)
            ->first();
    }
718160
protected function ensureLoaded( $domain, $lang ) {
		if ( isset( $this->loadedDomains[ $domain ][ $lang ] ) ) {
			// Already tried
			return $this->loadedDomains[ $domain ][ $lang ];
		}

		// Validate input and protect against path traversal
		if ( !IntuitionUtil::nonEmptyStrs( $domain, $lang ) ||
			strcspn( $domain, ":/\\\000" ) !== strlen( $domain ) ||
			strcspn( $lang, ":/\\\000" ) !== strlen( $lang )
		) {
			$this->errTrigger( 'Illegal domain or lang', __METHOD__, E_NOTICE );
			return false;
		}

		$this->loadedDomains[ $domain ][ $lang ] = false;

		if ( !isset( self::$messageCache[ $domain ][ $lang ] ) ) {
			// Load from disk
			$domainInfo = $this->getDomainInfo( $domain );
			if ( !$domainInfo ) {
				// Unknown domain. Perhaps dev-mode only with
				// messages provided via setMsgs()?
				return false;
			}
			$file = $domainInfo['dir'] . "/$lang.json";
			$this->loadMessageFile( $domain, $lang, $file );
		} else {
			// Load from static cache, e.g. from a previous instance of this class
			$this->setMsgs( self::$messageCache[ $domain ][ $lang ], $domain, $lang );
		}

		$this->loadedDomains[ $domain ][ $lang ] = true;
		return true;
	}
803127
public function getNamesForDomain($domain)
    {
        if (!isset($this->templates[$domain])) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown template domain "%s"',
                $domain
            ));
        }

        return array_keys($this->templates[$domain]);
    }
633839
public function getCatalogs($locale = null, $domain = null) {
		if ($locale === null && $domain === null) {
			return $this->catalogs;
		}
		
		if (is_string($locale)) {
			return $this->getSingleCatalog($locale, $domain);
		}
		
		if (is_array($locale)) {
			return $this->getManyCatalogs($locale, $domain);
		}
		
		throw new InvalidParameter('Locale must be a string or an array');
	}
1227969
public function getTranslations(
        array $domains = [],
        array $languages = [],
        callable $filter = null
    ) : array {
        $translations = array_filter(
            $this->translations,
            function (Translation $translation) {
                return $translation->getValue() != '';
            }
        );

        if (is_callable($filter)) {
            $translations = array_filter(
                $translations,
                $filter
            );
        }

        return $translations;
    }
848863
protected function handlePreinit($locale, $domain) {
		if (! empty($this->preinitLocales)) {
			$locale = array_unique(array_merge(
				(array) $locale, 
				$this->preinitLocales
			));
		}

		if (! empty($this->preinitDomains)) {
			$domain = array_unique(array_merge(
				(array) $domain,
				$this->preinitDomains
			));
		}
		
		$this->preinitNeed = false;
		
		return [$locale, $domain];
	}
283613
public function getAllDomainsByLocale()
    {
        $reduce = <<<FCT
function (obj, prev) {
    if (typeof(prev.couples) == 'undefined') { prev.couples = new Array(); }

    if (typeof(obj.translations) != 'undefined') {
        obj.translations.forEach(function (translation) {
            var i = 0, found = false;
            while (i<prev.couples.length && !found) {
                found = (prev.couples[i].locale == translation['locale'] && prev.couples[i].domain == obj.domain);
                i++;
            }
            if (!found) { prev.couples.push({"locale": translation['locale'], "domain": obj.domain}); }
        });
    }
}
FCT;

        $results = $this->createQueryBuilder()
            ->hydrate(false)
            ->group(array(), array('couples' => array()))
            ->reduce($reduce)
            ->sort(array('translations.locale' => 'asc', 'domain' => 'asc'))
            ->getQuery()
            ->execute();

        $couples = array();

        if (isset($results[0], $results[0]['couples'])) {
            $couples = $results[0]['couples'];

            usort($couples, function ($a, $b) {
                $result = strcmp($a['locale'], $b['locale']);
                if (0 === $result) {
                    $result = strcmp($a['domain'], $b['domain']);
                }
                return $result;
            });
        }

        return $couples;
    }
1012815
public function dpgettext($domain, $context, $original)
    {
        $translation = $this->getTranslation($domain, $context, $original);

        if (isset($translation[0]) && $translation[0] !== '') {
            return $translation[0];
        }

        return $original;
    }
946963
public function getTranslations(string $page, ?string $locale = null): array
    {
        $config = $this->getPageConfig($page);

        $messages = [];
        $catalogue = $this->translatorBag->getCatalogue($locale);

        foreach ($config as $domain => $keys) {
            foreach ($this->getMessages($catalogue, $domain, $keys) as $domainLocale => $messageStrings) {
                if (!$messageStrings) {
                    continue;
                }

                if (!array_key_exists($domainLocale, $messages)) {
                    $messages[$domainLocale] = [];
                }

                $messages[$domainLocale][$domain] = $messageStrings;
            }
        }

        return $messages;

    }
165363
public static function getXDomainId($domain)
	{
		$db = \App::get('db');

		if (empty($domain) || ($domain == 'hubzero'))
		{
			return false;
		}

		$query = 'SELECT domain_id FROM `#__xdomains` WHERE domain=' . $db->quote($domain) . ';';
		$db->setQuery($query);

		$result = $db->loadObject();

		if (empty($result))
		{
			return false;
		}

		return $result->domain_id;
	}