Create a catalogue from the contents of a XLIFF file.

@param string $content
@param string $locale
@param string $domain

@return MessageCatalogue
14505
public static function contentToCatalogue($content, $locale, $domain)
    {
        $loader = new XliffLoader();
        $catalogue = new MessageCatalogue($locale);
        $loader->extractFromContent($content, $catalogue, $domain);

        return $catalogue;
    }
324411
protected function getValue($string, $domain, $locale)
    {
        if (!$domain) {
            $domain = 'default';
        }

        $this->loadDomain($domain, $locale);

        // We have to treat 'languages', 'default', 'modules' etc. domains differently.
        if (!(isset($GLOBALS['TL_LANG'][$domain]) && is_array($GLOBALS['TL_LANG'][$domain]))
            && (substr($domain, 0, 2) != 'tl_')
        ) {
            $lang = $GLOBALS['TL_LANG'];
        } else {
            if (!is_array($GLOBALS['TL_LANG'][$domain])) {
                return $string;
            }
            $lang = $GLOBALS['TL_LANG'][$domain];
        }

        $chunks = explode('.', $string);

        while (($chunk = array_shift($chunks)) !== null) {
            if (!array_key_exists($chunk, $lang)) {
                return $string;
            }

            $lang = $lang[$chunk];
        }

        return $lang;
    }
366669
public static function create($resource, $format, $domain = null)
    {
        if (empty($domain)) {
            $domain = MessageCatalogueInterface::DEFAULT_DOMAIN;
        }
        $resource = new Resource($resource, $format, $domain);
        return $resource;
    }
987961
private function getCatalogue($locale)
    {
        if (empty($this->catalogues[$locale])) {
            $this->loadCatalogue($locale, $this->dir);
        }

        return $this->catalogues[$locale];
    }
1361108
public function registerMessage(string $domain, string $string, bool $resolveDomain = true)
    {
        if ($resolveDomain) {
            $domain = $this->config->resolveDomain($domain);
        }

        //Automatically registering
        $this->catalogue->set($domain, $string, $string);

        $this->getLogger()->debug(
            sprintf("[%s]: `%s`", $domain, $string),
            compact('domain', 'string')
        );
    }
250018
public static function create(Entry $entry, Locale $locale)
    {
        $result = new static();
        $result->entry = $entry;
        $result->locale = $locale;
        $result->comments = '';

        return $result;
    }
1024213
protected function loadDomain($domain, $locale)
    {
        $event = new LoadLanguageFileEvent($domain, $locale);

        $this->eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event);
    }
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');
	}
1362871
public static function create(string $text, string $locale = self::DEFAULT_LOCALE): self
    {
        return new self($text, $locale);
    }
1220198
protected function markAsInitialized($locale, $domain) {
		if (! isset($this->initializedCatalogs[$locale])) {
			$this->initializedCatalogs[$locale] = [];
		}

		$this->initializedCatalogs[$locale][$domain] = true;
	}
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 );
    }
901041
protected function createContentBlock($name, $locale, $type, $content)
    {
        $block = new ContentBlock();
        $block
            ->setName($name)
            ->setLocale($locale)
            ->setType($type)
            ->setContent($content)
            ->save()
        ;

        $this->blocks[$name][$locale] = $block;

        return $block;
    }
764266
public function create($data, $locale)
    {
        $excerpt = new ExcerptViewObject();

        if (empty($data)) {
            return $excerpt;
        }

        $excerpt->title = $data['title'];
        $excerpt->more = $data['more'];
        $excerpt->description = $data['description'];
        $excerpt->tags = $this->tagCollectionFactory->create($data['tags']);
        $excerpt->categories = $this->categoryCollectionFactory->create($data['categories'], $locale);
        $excerpt->icon = $this->mediaCollectionFactory->create($data['icon'], $locale);
        $excerpt->images = $this->mediaCollectionFactory->create($data['images'], $locale);

        return $excerpt;
    }
362683
private function getMessages(MessageCatalogueInterface $catalogue, string $domain, array $keys)
    {
        $current = $catalogue;
        $previous = [];
        $messages = [];

        while ($current !== null) {
            $all = $current->all($domain);

            if (count($keys) === 0 || in_array('*', $keys)) {
                $currentMessages = array_diff_key($all, $previous);
            } else {
                $currentMessages = [];

                foreach ($keys as $key) {
                    if (substr($key, -1) === '*') {
                        $currentMessages += $this->findWildcardMessages($key, $all, $previous);
                    } else if (!array_key_exists($key, $previous) && array_key_exists($key, $all)) {
                        $currentMessages[$key] = $all[$key];
                    }
                }
            }

            $messages[$current->getLocale()] = $previous = $currentMessages;
            $current = $current->getFallbackCatalogue();
        }

        return $messages;
    }
732855
public function trans($id, array $parameters = [], $domain = null, $locale = null)
    {
        if (null === $locale) {
            $locale = $this->getLocale();
        }

        if (null === $domain) {
            $domain = 'messages';
        }

        if (!isset($this->catalogues[$locale])) {
            $this->loadCatalogue($locale);
        }

        // Change translation domain to 'messages' if a translation can't be found in the
        // current domain
        if ('messages' !== $domain && false === $this->catalogues[$locale]->has((string) $id, $domain)) {
            $domain = 'messages';
        }

        return strtr($this->catalogues[$locale]->get((string) $id, $domain), $parameters);
    }
176221
protected function initCatalogs($locale, $domain) {
		if (empty($this->resources)) {
			throw new NoResources('Resources hasn\'t been provided');
		}
		
		// Add the preinit data to the request if need
		if ($this->preinitNeed) {
			list($locale, $domain) = $this->handlePreinit($locale, $domain);
		}
		
		// Mark as initialized anyway
		$this->markAsInitialized($locale, $domain);
		
		// Try from cache
		if ($this->cache !== null) {
			$catalogsCached = $this->cache->getCatalogs($locale, $domain);
			
			if ($catalogsCached !== null) {
				$this->catalogs = array_replace_recursive($this->catalogs, $catalogsCached);
				
				// Request to the resources is still need ?
				$requestDiff = $this->calculateRequestDiff($locale, $domain, $catalogsCached);
				
				if ($requestDiff === null) {
					return;
				}
				
				list($locale, $domain) = $requestDiff;
			}
		}
		
		// Try from resources
		$catalogs = $this->getCatalogsFromResources($locale, $domain);
		
		if (! empty($catalogs)) {
			$this->catalogs = array_replace_recursive($this->catalogs, $catalogs);
			
			// Store in the cache just obtained data
			if ($this->cache !== null) {
				$this->cache->setCatalogs($catalogs);
			}
		}
	}
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;
    }