Load a locale file into the translator

@param string $file
@param string $domain
165563
public function loadLocaleFile($file, $domain) {
		$filename = $this->findLocaleFile($file);

		if ($filename !== null) {
			$locale = $this->getLocaleFromFilename($filename);
			$translator = $this->service->getTranslator();
			$translator->addResource('json', $filename, $locale, $domain);
		}
	}
676534
private function importSingleTranslation($keyword, $text, $locale, $filename, $domain, $force = false)
    {
        if (strlen($keyword) > 255) {
            return false;
        }

        $translationGroup = $this->translationGroupManager->getTranslationGroupByKeywordAndDomain($keyword, $domain);

        if (!$translationGroup->hasTranslation($locale)) {
            $this->translationGroupManager->addTranslation($translationGroup, $locale, $text, $filename);

            return true;
        }

        if (true === $force) {
            $this->translationGroupManager->updateTranslation($translationGroup, $locale, $text, $filename);

            return true;
        }

        return false;
    }
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);
    }
780546
protected function initCatalog($locale, $domain) {
		if (isset($this->initializedCatalogs[$locale][$domain])) {
			return;
		}
		
		$content = $this->getCatalogContent($locale, $domain);
		
		if ($content === false) {
			$this->markAsInitialized($locale, $domain);
			return;
		}
		
		$catalog = $this->parseContent($content);
		
		if (! isset($this->catalogs[$locale])) {
			$this->catalogs[$locale] = [];
		}
		
		$this->catalogs[$locale][$domain] = $catalog;
		
		$this->markAsInitialized($locale, $domain);
	}
726411
protected function importBundleTranslationFiles(BundleInterface $bundle, $locales, $domains, $global = false)
    {
        $path = $bundle->getPath();
        if ($global) {
            $path = $this->getApplication()->getKernel()->getRootDir() . '/Resources/' . $bundle->getName() . '/translations';
            $this->output->writeln('<info>*** Importing ' . $bundle->getName() . '`s translation files from ' . $path . ' ***</info>');
        }

        $this->output->writeln(sprintf('<info># %s:</info>', $bundle->getName()));
        $finder = $this->findTranslationsFiles($path, $locales, $domains);
        $this->importTranslationFiles($finder);
    }
808979
private function getTranslationFilesFromConfiguration($domain, $locale)
    {
        $filteredFilenames = array();

        foreach ($this->translationFilesByLocale as $localeFromConfig => $resourceFilePaths) {
            foreach ($resourceFilePaths as $filename) {
                list($currentDomain, $currentLocale) = explode('.', basename($filename), 3);

                if ($currentDomain === $domain && $currentLocale === $locale) {
                    $filteredFilenames[] = $filename;
                }
            }
        }
        return $filteredFilenames;
    }
590242
public function load($lang) {
        $langDir = MODULES_DIR . DS . RouteController::$currentModule . '/Views/lang/' . $lang;

        $files = glob($langDir . "/*.php");
        if (count($files) == 0) {
            throw new \Exception(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND);
        }

        foreach ($files as $file) {
            $fileInfo = pathinfo($file);
            self::$translations[$fileInfo['filename']] = require_once $file;
        }
    }
397163
private function loadTranslations($language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

        if (!isset($this->translations[$language])) {
            $this->translations[$language] = [];
        }

        if (isset($this->files[$language])) {
            foreach ($this->files[$language] as $file) {
                if (is_file($file)) {
                    $this->translations[$language] = array_merge(
                        $this->translations[$language],
                        $this->getTranslationArrayFromFile($file)
                    );
                } elseif (is_dir($file)) {
                    $it = new \RecursiveDirectoryIterator($file, \FilesystemIterator::SKIP_DOTS);
                    $it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST);

                    foreach ($it as $file) {
                        if (is_file($file->getRealPath())) {
                            $this->translations[$language] = array_merge(
                                $this->translations[$language],
                                $this->getTranslationArrayFromFile($file->getRealPath()));
                        }
                    }
                }
            }
        }
    }
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);
    }
1520
public function load($resource, $locale, $domain = 'messages') {
		$repo = $this->service->getResourceRepository();
		if (!$repo->contains($resource)) {
			throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
		}

		// find file in puli repo
		$file = $repo->get($resource);
		$json = $file->getBody();
		$data = Json::decode($json);
		$messages = [];

		// flatten plural strings
		foreach ($data as $key => $value) {
			if (is_array($value)) {
				$vals = [];
				foreach ($value as $k => $v) {
					$vals[] = sprintf('%s: %s', $k, $v);
				}
				$val = implode('|', $vals);
			} else {
				$val = $value;
			}

			$messages[$key] = str_replace(['{{', '}}'], '%', $val);
		}

		// put them into message catalog
		$catalogue = new MessageCatalogue($locale);
		$catalogue->add($messages, $domain);

		return $catalogue;
	}
674387
public function loadLanguage()
    {
        $package = $this->getIdentifier()->package;
        $domain  = $this->getIdentifier()->domain;

        if($domain) {
            $url = 'com://'.$domain.'/'.$package;
        } else {
            $url = 'com:'.$package;
        }

        $this->getObject('translator')->load($url);
    }
643261
protected function loadLanguageFile($file, $format)
    {
        if (is_file($file)) {
            $this->load($file, $format);

            $loaded = $this->config['language.loaded'];

            $loaded[] = $file;

            $this->config->set('language.loaded', $loaded);
        }

        return $this;
    }
30224
protected function _getTranslations( $domain )
	{
		if( !isset( $this->_translations[$domain] ) )
		{
			if ( !isset( $this->_translationSources[$domain] ) )
			{
				$msg = sprintf( 'No translation directory for domain "%1$s" available', $domain );
				throw new MW_Translation_Exception( $msg );
			}

			// Reverse locations so the former gets not overwritten by the later
			$locations = array_reverse( $this->_getTranslationFileLocations( $this->_translationSources[$domain], $this->getLocale() ) );
			$options = $this->_options;

			foreach( $locations as $location )
			{
				$options['content'] = $location;
				$this->_translations[$domain][] = new Zend_Translate( $options );
			}
		}

		return ( isset( $this->_translations[$domain] ) ? $this->_translations[$domain] : array() );
	}
151928
public function load($file,$context)
	{
		$pattern='/(msgctxt\s+"(.*?(?<!\\\\))")?\s+'
			.'msgid\s+((?:".*(?<!\\\\)"\s*)+)\s+'
			.'msgstr\s+((?:".*(?<!\\\\)"\s*)+)/';
		$matches=array();
		$n=preg_match_all($pattern,file_get_contents($file),$matches);

		$messages=array();
		for($i=0; $i<$n; $i++)
		{
			if($matches[2][$i]===$context)
			{
				$id=$this->decode($matches[3][$i]);
				$message=$this->decode($matches[4][$i]);
				$messages[$id]=$message;
			}
		}
		return $messages;
	}
783182
public function load($locale)
    {
        if (isset($this->cache[$locale])) {
            return $this->cache[$locale];
        }

        // New Translator array
        $trans = [];
        // Split the language: language, region, locale, etc
        $parts = string_split($locale, '-');

        do {
            // Create a path for this set of parts
            $path = implode(DS, $parts);

            // Remove the last part
            if ($files = $this->findLanguageFile($path)) {
                $trans = $this->loadMessages($files, $trans);
            }

            array_pop($parts);
        } while ($parts);

        // Cache the Translator table locally
        return $this->cache[$locale] = $trans;
    }
428229
protected function initCatalogsForManyLocales($locales, $domain) {
		foreach ($locales as $locale) {
			$this->initCatalogsForSingleLocale($locale, $domain);
		}
	}
541902
public function load($locale, $filename)
    {
        $textDomain = parent::load($locale, $filename);

        $localeInfo = Language::getById($locale);
        if ($localeInfo !== null) {
            $this->fixPlurals($filename, $textDomain, $localeInfo);
        }

        return $textDomain;
    }