Load

@param mixed $resource
@param string $locale
@param string $domain
@return MessageCatalogue
559332
public function load($resource, $locale, $domain = 'messages')
    {
        $catalogue = new MessageCatalogue($locale);

        foreach ($this->repository->getTranslations($locale, $domain) as $id => $translation) {
            $catalogue->set($id, $translation, $domain);
        }

        return $catalogue;
    }
288874
public function getCatalogs($locale = null, $domain = null) {
		$cache = $this->getCacheFrontend();
		
		if (is_array($domain)) {
			$catalogs = $cache->getMany($domain);
			
			if (empty($catalogs)) {
				return;
			}
			
			return call_user_func_array('array_replace_recursive', $catalogs);
		}
		
		return $cache->get($domain);
	}
876000
public function load($locale, $group, $namespace = null)
    {
        $defaults = [];

        foreach ($this->paths as $path) {
            $defaults = array_replace_recursive($defaults, $this->loadPath($path, $locale, $group));
        }

        return array_replace_recursive($defaults, parent::load($locale, $group, $namespace));
    }
110161
protected function loadMessages($path, $locale)
    {
        $filePath = $path . $locale . '.yml';
        $messages = $this->getReader()->read($locale, $filePath);
        return $this->normaliseMessages($messages, $locale);
    }
1102993
public function build($locale, $domain = 'gui')
    {
        $cache = new ConfigCache($this->cacheDir.'/translations-'.$locale.'.js', $this->debug);

        if (!$cache->isFresh()) {
            $content = $this->buildContent($locale, $domain);

            $cache->write($content->getContent(), $content->getResources());

            if (!$this->debug) {
                $this->compressor->compressFile((string) $cache);
            }
        }

        return new Asset((string) $cache);
    }
460503
public function getAllByLocaleAndDomain($locale, $domain)
    {
        $results = $this->createQueryBuilder()
            ->hydrate(false)
            ->field('domain')->equals($domain)
            ->field('translations.locale')->equals($locale)
            ->sort('key', 'asc')
            ->getQuery()
            ->execute();

        $values = array();
        foreach ($results as $item) {
            $i = 0;
            $index = null;
            while ($i < $item['translations'] && null === $index) {
                if ($item['translations'][$i]['locale'] == $locale) {
                    $index = $i;
                }
                $i++;
            }
            $item['translations'] = array($item['translations'][$i - 1]);
            $values[] = $item;
        }

        return $values;
    }
1142178
public function trans(
        $id,
        array $parameters = array(),
        $domain = 'core',
        $locale = null,
        $return_default_if_not_available = true,
        $useFallback = true
    ) {
        if (null === $locale) {
            $locale = $this->getLocale();
        }

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

        // global translations
        if ($useFallback) {
            $fallbackId = sprintf(self::GLOBAL_FALLBACK_KEY, $domain, (string) $id);

            if ($this->catalogues[$locale]->has($fallbackId, self::GLOBAL_FALLBACK_DOMAIN)) {
                return parent::trans($fallbackId, $parameters, self::GLOBAL_FALLBACK_DOMAIN, $locale);
            }

            if ($this->catalogues[$locale]->has($id, self::GLOBAL_FALLBACK_DOMAIN)) {
                // global translations
                return parent::trans($id, $parameters, self::GLOBAL_FALLBACK_DOMAIN, $locale);
            }
        }

        if ($this->catalogues[$locale]->has((string) $id, $domain)) {
            return parent::trans($id, $parameters, $domain, $locale);
        } else {
            if ($return_default_if_not_available) {
                return strtr($id, $parameters);
            } else {
                return '';
            }
        }
    }
854012
public static function t($message, $args = [], $domain = 'core', $locale = 'en_EN')
    {
        return self::getInstance()->translator->trans($message, $args, $domain, $locale);
    }
988172
protected function getSingleCatalog($locale, $domain = null) {
		if (! isset($this->catalogs[$locale])) {
				 return [];
		}

		if ($domain === null) {
			return [$locale => $this->catalogs[$locale]];
		}

		if (is_string($domain)) {
			if (! isset($this->catalogs[$locale][$domain])) {
				return [];
			}

			return [
				$locale => [
					$domain => $this->catalogs[$locale][$domain]
				]
			];
		}

		if (is_array($domain)) {
			return [$locale => array_intersect_key(
				$this->catalogs[$locale],
				array_flip($domain))
			];
		}
		
		throw new InvalidParameter('Domain must be a string or an array');
	}
422169
public function load($locale, $group, $namespace = null)
	{
		if (is_null($namespace) || $namespace == '*')
		{
			return $this->loadData($locale, $group);
		}

		return $this->loadNamespaced($locale, $group, $namespace);
	}
207294
protected function loadMessagesFromFile($locale)
    {
        if (isset($this->messages[$locale])) {
            return true;
        }

        return $this->resetMessages($locale);
    }
1352709
public function getMessageCatalogues($locale, $domain)
    {
        $catalogue = new MessageCatalogue($locale);
        $units = $this->findByDomain($domain);
        $translations = array();
        foreach ($units as $unit) {
            if ($unit->hasTranslation($locale)) {
                $translations[$unit->getKey()] = $unit->getTranslation($locale)->getValue();
            }
        }

        $catalogue->add($translations, $domain);

        return $catalogue;
    }
1235323
protected function getCatalogContent($locale, $domain) {
		$path = $this->getCatalogPath($locale, $domain);
		
		if (! is_file($path)) {
			return false;
		}
		
		if (! is_readable($path)) {
			throw new ReadError('Catalog file: "' . $path . '" exists but can\'t be read');
		}
		
		$result = file_get_contents($path);
		
		if ($result === false) {
			throw new ReadError('Error has occurred while reading the file: "' . $path . '"');
		}
		
		$this->lastFilePath = $path;
		
		return $result;
	}
329167
private function loadCatalogue($locale, array $dirs)
    {
        $currentCatalogue = new MessageCatalogue($locale);
        foreach ($dirs as $path) {
            if (is_dir($path)) {
                $this->reader->read($path, $currentCatalogue);
            }
        }

        $this->catalogues[$locale] = $currentCatalogue;
    }
936355
public function findTranslation($domain, $key, $locale, $nullWhenNotFound = false)
    {
        // Get the unit
        try {
            $unit = $this->findByDomainAndKey($domain, $key);
        } catch (NotFoundException $e) {
            if ($nullWhenNotFound) {
                return;
            }
            throw $e;
        }

        // Check translation
        if ($unit && $unit->hasTranslation($locale)) {
            return $unit->getTranslation($locale);
        }

        return;
    }
1164518
private function buildContent($locale, $domain)
    {
        $translations = [];
        $resources = [];

        if ($locale !== $this->fallbackLocale) {
            $fallbackCatalogue = $this->translator->getCatalogue($this->fallbackLocale);
            $resources = array_merge($resources, $fallbackCatalogue->getResources());
            $translations = array_merge($translations, $this->extractor->extract($fallbackCatalogue, $domain));
        }

        $catalogue = $this->translator->getCatalogue($locale);
        $resources = array_merge($resources, $catalogue->getResources());
        $translations = array_merge($translations, $this->extractor->extract($catalogue, $domain));

        $content = $this->builder->build($translations, $locale);

        return new ResourceContent($content, $resources);
    }
987961
private function getCatalogue($locale)
    {
        if (empty($this->catalogues[$locale])) {
            $this->loadCatalogue($locale, $this->dir);
        }

        return $this->catalogues[$locale];
    }