Get the many of translation's catalogs for the many locales [and domain(s)]

@param  array          $locale
@param  string | array $domain
@return array
@throws InvalidParameter
161720
protected function getManyCatalogs(array $locale, $domain = null) {
		if ($domain === null) {
			return array_intersect_key(
				$this->catalogs,
				array_flip($locale)
			);
		}

		if (is_string($domain)) {
			$result = [];

			foreach ($locale as $part) {
				if (isset($this->catalogs[$part][$domain])) {
					$result[$part][$domain] = $this->catalogs[$part][$domain];
				}
			}

			return $result;
		}

		if (is_array($domain)) {
			$result = [];

			foreach ($locale as $part) {
				if (isset($this->catalogs[$part])) {
					$result[$part] = array_intersect_key(
						$this->catalogs[$part],
						array_flip($domain)
					);
				}
			}

			return $result;
		}

		throw new InvalidParameter('Domain must be a string or an array');
	}
135937
private function buildPath($domain, $locale)
    {
        $path = '/resources/translations/' . $locale . '/' . $domain . '.' . $locale . '.yml';

        // If long locale dir doesn't exists try short locale and return it if that exists
        if (strlen($locale) == 5 && !is_dir($this->app['path_resolver']->resolve('%root%/app' . $path))) {
            $paths = $this->buildPath($domain, substr($locale, 0, 2));

            if (is_dir($paths[0])) {
                return $paths;
            }
        }

        return [
            $this->app['path_resolver']->resolve('%root%/app' . $path),
            'app' . $path,
        ];
    }
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;
    }
51182
private function log($id, $domain, $locale)
    {
        if (null === $domain) {
            $domain = 'messages';
        }

        $id = (string) $id;
        $catalogue = $this->translator->getCatalogue($locale);
        if ($catalogue->defines($id, $domain)) {
            return;
        }

        if ($catalogue->has($id, $domain)) {
            $this->logger->debug('Translation use fallback catalogue.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
        } else {
            $this->logger->warning('Translation not found.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
        }
    }
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;
    }
514714
public function getAll( $domain )
	{
		$messages = [];

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

		return $messages;
	}
231060
protected function initCatalogForManyDomains($locale, $domains) {
		foreach ($domains as $domain) {
			$this->initCatalog($locale, $domain);
		}
	}
235231
public function load($locale)
    {
        if ($this->files->exists($full = $this->path."/".$locale.".lang")) {
            return $this->loadFileData($this->files->get($full));
        }
        return [];
    }
1161870
public function findForLocalesAndDomains(array $locales, array $domains)
    {
        return FileQuery::create()
            ->_if(count($locales) > 0)
                ->filterByLocale($locales, Criteria::IN)
            ->_endif()

            ->_if(count($domains) > 0)
                ->filterByDomain($domains, Criteria::IN)
            ->_endif()

            ->find($this->getConnection())
        ;
    }
12474
public static function getLocaleFallbackList($locale, $fallbackLocale = '')
    {
        // Check arguments
        if (empty($locale)) {
            throw new InvalidArgumentException(__METHOD__ . ': The given locale is empty');
        }

        // Create a priority fallback list to check for different locale.
        // This list includes also generic language codes separated from locale in case
        // there is generic language fallback.
        // If the base language for current and fallback locale is the same, then the language code
        // goes in the end as final fallback.
        $fallbackList = [];

        // Get fallback for normal locale
        $fallbackList = array_merge($fallbackList, self::getFallbackList($locale));

        // Add fallback locale, if different
        if ($fallbackLocale != $locale) {
            $fallbackList = array_merge($fallbackList, self::getFallbackList($fallbackLocale));
        }

        return $fallbackList;
    }
599532
public static function getDisplayLocales($locale)
    {
        if (!isset(self::$locales[$locale])) {
            self::$locales[$locale] = Intl::getLocaleBundle()->getLocaleNames($locale);
        }

        return self::$locales[$locale];
    }
4096
private function getTranslationsForDomainAndIds($locale, $domain, $ids)
    {
        /** @var Translator $translator */
        $translator = $this->container->get('translator');

        $translations = [];
        foreach ($ids as $id) {
            $translations[$id] = $translator->trans($id, [], $domain, $locale);
        }

        return $translations;
    }
1160191
public function getCatalogs($locale = null, $domain = null) {
		$cache   = $this->getCacheFrontend();
		$cacheId = $this->prepareCacheId($locale, $domain);
		
		// Many
		if (is_array($cacheId)) {
			$catalogsRaw = $cache->getMany($cacheId);
			
			if (empty($catalogsRaw)) {
				return;
			}
			
			$catalogs = [];
			
			foreach ($catalogsRaw as $catalogId => $catalog) {
				list($localePart, $domainPart) = explode('_', $catalogId);
				
				if (! isset($catalogs[$localePart])) {
					$catalogs[$localePart] = [];
				}
				
				$catalogs[$localePart][$domainPart] = $catalog;
			}
			
			return $catalogs;
		}
		
		// One
		$catalog = $cache->get($cacheId);
				
		if ($catalog === null) {
			return;
		}

		return [
			$locale => [
				$domain => $catalog
			]
		];
	}
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];
	}
431823
protected function t($key, array $parameters = [], $domain = null, $locale = null)
    {
        return $this->getContainer()->get('translator')->trans($key, $parameters, $domain, $locale);
    }
356862
public function getTranslations(
        array $domains = [],
        array $languages = [],
        callable $filter = null
    ) : array {
        return $this
            ->repositoryCollection
            ->getTranslations(
                $domains,
                $languages,
                $filter
            );
    }
621877
public function removeCatalogs($locale = null, $domain = null) {
		$cache = $this->getCacheFrontend();
		
		if (is_array($domain)) {
			return $cache->removeMany($domain);
		}
		
		return $cache->remove($domain);
	}