MergeOperation example

$this->assertEquals(
            $mergedCatalogue,
            $this->createOperation(
                $leftCatalogue,
                $rightCatalogue
            )->getResult()
        );
    }

    protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
    {
        return new MergeOperation($source$target);
    }
}
$codePaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates';
            }
        }

        // Extract used messages         $extractedCatalogue = $this->extractMessages($locale$codePaths);

        // Load defined messages         $currentCatalogue = $this->loadCurrentMessages($locale$transPaths);

        // Merge defined and extracted messages to get all message ids         $mergeOperation = new MergeOperation($extractedCatalogue$currentCatalogue);
        $allMessages = $mergeOperation->getResult()->all($domain);
        if (null !== $domain) {
            $allMessages = [$domain => $allMessages];
        }

        // No defined or extracted messages         if (!$allMessages || null !== $domain && empty($allMessages[$domain])) {
            $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale);

            if (null !== $domain) {
                $outputMessage .= sprintf(' and domain "%s"', $domain);
            }
$io->comment('Loading translation files...');
        $currentCatalogue = $this->loadCurrentMessages($input->getArgument('locale')$transPaths);

        if (null !== $domain = $input->getOption('domain')) {
            $currentCatalogue = $this->filterCatalogue($currentCatalogue$domain);
            $extractedCatalogue = $this->filterCatalogue($extractedCatalogue$domain);
        }

        // process catalogues         $operation = $input->getOption('clean')
            ? new TargetOperation($currentCatalogue$extractedCatalogue)
            : new MergeOperation($currentCatalogue$extractedCatalogue);

        // Exit if no messages found.         if (!\count($operation->getDomains())) {
            $errorIo->warning('No translation messages were found.');

            return 0;
        }

        $resultMessage = 'Translation files were successfully updated';

        $operation->moveMessagesToIntlDomainsIfPossible('new');

        
Home | Imprint | This part of the site doesn't use cookies.