You are here

public function MessageCatalogue::addCatalogue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/MessageCatalogue.php \Symfony\Component\Translation\MessageCatalogue::addCatalogue()

Merges translations from the given Catalogue into the current one.

The two catalogues must have the same locale.

Parameters

MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance:

Overrides MessageCatalogueInterface::addCatalogue

File

vendor/symfony/translation/MessageCatalogue.php, line 143

Class

MessageCatalogue
MessageCatalogue.

Namespace

Symfony\Component\Translation

Code

public function addCatalogue(MessageCatalogueInterface $catalogue) {
  if ($catalogue
    ->getLocale() !== $this->locale) {
    throw new \LogicException(sprintf('Cannot add a catalogue for locale "%s" as the current locale for this catalogue is "%s"', $catalogue
      ->getLocale(), $this->locale));
  }
  foreach ($catalogue
    ->all() as $domain => $messages) {
    $this
      ->add($messages, $domain);
  }
  foreach ($catalogue
    ->getResources() as $resource) {
    $this
      ->addResource($resource);
  }
  if ($catalogue instanceof MetadataAwareInterface) {
    $metadata = $catalogue
      ->getMetadata('', '');
    $this
      ->addMetadata($metadata);
  }
}