Load catalogue from files.

@param string $locale
@param array  $dirs
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;
    }
1267398
public function load($namespace, $group, $locale)
    {
        if ($this->isLoaded($namespace, $group, $locale)) {
            return;
        }

        // The loader is responsible for returning the array of language lines for the
        // given namespace, group, and locale. We'll set the lines in this array of
        // lines that have already been loaded so that we can easily access them.
        $lines = $this->loader->load($locale, $group, $namespace);

        $this->loaded[$namespace][$group][$locale] = $lines;
    }
207366
protected function initManyLocales($locale, $domain) {
		$source = $this->getCatalogContent($locale, $domain);
		
		if ($source !== false) {
			$locales = parse_ini_string($source, true);
			
			if ($locales === false) {
				throw new ParseError('Error has occurred while parsing INI file for the domain: "' . $domain . '"');
			}
			
			foreach ($locales as $locale => $catalog) {
				$this->catalogs = array_replace_recursive($this->catalogs, [
					$locale => [
						$domain => $catalog
					]
				]);
			}
		}

		if (! isset($this->initializedCatalogs[$locale])) {
			$this->initializedCatalogs[$locale] = [];
		}

		foreach (array_keys($locales) as $locale) {
			$this->initializedCatalogs[$locale][$domain] = true;
		}
	}
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;
    }
859794
private function setLocale($locale)
    {
        $path = __DIR__ . DIRECTORY_SEPARATOR .
            'assets' . DIRECTORY_SEPARATOR .
            'php' . DIRECTORY_SEPARATOR .
            'locale' . DIRECTORY_SEPARATOR . $locale . '.php';

        if (!file_exists($path)) {
            $this->locale = 'en';
            $path = __DIR__ . DIRECTORY_SEPARATOR .
                'assets' . DIRECTORY_SEPARATOR .
                'php' . DIRECTORY_SEPARATOR .
                'locale' . DIRECTORY_SEPARATOR . $this->locale . '.php';
        }
        $this->data = require_once($path);
    }
128252
public function getCatalogs($locale = null, $domain = null) {
		$cache = $this->getCacheFrontend();
		
		if (is_array($locale)) {
			$catalogs = $cache->getMany($locale);
			
			return empty($catalogs) ? null : $catalogs;
		}
		
		$catalogs = $cache->get($locale);
		
		if ($catalogs === null) {
			return;
		}
		
		return [$locale => $catalogs];
	}
434376
protected function importBundlesTranslationFiles(array $locales, array $domains, $global = false)
    {
        $bundles = $this->getApplication()->getKernel()->getBundles();

        foreach ($bundles as $bundle) {
            $this->importBundleTranslationFiles($bundle, $locales, $domains, $global);
        }
    }
428229
protected function initCatalogsForManyLocales($locales, $domain) {
		foreach ($locales as $locale) {
			$this->initCatalogsForSingleLocale($locale, $domain);
		}
	}
1292952
public function setLocales(array $locales) {
        $this->locales = [];
        foreach($locales as $loc)
            $this->addLocale($loc);
    }
604274
public function setFallbackLocales(array $locales)
    {
        // needed as the fallback locales are linked to the already loaded catalogues
        $this->resetCatalogues();
        foreach ($locales as $locale) {
            LocaleValidator::assertValidLocale($locale);
        }
        $this->fallbackLocales = $locales;
    }
649822
public function loadFolder($path, $namespace = '__main__')
  {
      if (is_dir($path)) {
          $files = glob($path.'*.php');
          if (!defined('DS')) {
              define('DS', DIRECTORY_SEPARATOR);
          }
          foreach ($files as $file) {
              $shell = explode(DS, $file);
              $fileName = end($shell);
              $fileName = explode('.', $fileName, -1);
              $prefix = '';
              if (count($fileName) == 2) {
                  $prefix = reset($fileName).'.';
                  $locale = end($fileName);
              } else {
                  $locale = end($fileName);
              }
              $translations = require $file;
              $translations = array_dot($translations, $prefix);

              // merge $namespace arrays with prefixed arrays if exists
              if (isset($this->translations[$locale])) {
                  if (isset($this->translations[$locale][$namespace])) {
                      $translations = array_merge($this->translations[$locale][$namespace], $translations);
                  }
              }

              // Save the values in our instance array
              $this->translations[$locale][$namespace] = $translations;
          }
      }
  }
713704
public function create($categoryIds, $locale)
    {
        if (empty($categoryIds)) {
            return new Collection();
        }

        // Load category with keywords
        $queryBuilder = $this->categoryRepository->createQueryBuilder('category')
            ->select(['category.id', 'category.key', 'translate.translation as name', 'keyword.keyword'])
            ->leftJoin('category.translations', 'translate', Join::WITH, 'translate.locale = :locale')
            ->setParameter('locale', $locale)
            ->leftJoin('translate.keywords', 'keyword');

        $queryBuilder->where($queryBuilder->expr()->in('category.id', $categoryIds));

        $categories = [];

        foreach ($queryBuilder->getQuery()->getResult() as $categoryData) {
            $id = (int) $categoryData['id'];

            if (!isset($categories[$id])) {
                $categories[$id] = new CategoryViewObject();
                $categories[$id]->id = $id;
                $categories[$id]->key = $categoryData['key'];
                $categories[$id]->name = $categoryData['name'];
            }

            $categories[$id]->keywords[] = $categoryData['keyword'];
        }

        return new Collection(array_values($categories));
    }
683336
protected function initLocale($locale)
    {
        $file = $this->localeDir . '/' . $locale . '.php';
        if (file_exists($file)) {
            $data = include $file;

            if (!is_array($data)) {
                $data = [];
            }
        } else {
            $data = [];
        }

        if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) {
            $data['pluralForm'] = null;
        }
        if (!isset($data['texts'])) {
            $data['texts'] = [];
        }

        $this->data[$locale] = $data;
    }
1024213
protected function loadDomain($domain, $locale)
    {
        $event = new LoadLanguageFileEvent($domain, $locale);

        $this->eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event);
    }
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);
			}
		}
	}
1165052
public function setLocale($locale)
    {
        if($this->_locale != $locale)
        {
            $this->_locale = $locale;

            //Set locale information for date and time formatting
            setlocale(LC_TIME, $locale);

            //Sets the default runtime locale
            if (function_exists('locale_set_default') ) {
                locale_set_default($locale);
            }

            //Clear the catalogue
            $this->getCatalogue()->clear();

            //Load the library translations
            $this->load(dirname(dirname(__FILE__)).'/resources/language');
        }

        return $this;
    }
784280
public function SetImportDirs( $dirs ){
		Less_Parser::$options['import_dirs'] = array();

		foreach($dirs as $path => $uri_root){

			$path = self::WinPath($path);
			if( !empty($path) ){
				$path = rtrim($path,'/').'/';
			}

			if ( !is_callable($uri_root) ){
				$uri_root = self::WinPath($uri_root);
				if( !empty($uri_root) ){
					$uri_root = rtrim($uri_root,'/').'/';
				}
			}

			Less_Parser::$options['import_dirs'][$path] = $uri_root;
		}
	}