filterCatalogue example


        $bag = new TranslatorBag();

        foreach ($locales as $locale) {
            $catalogue = new MessageCatalogue($locale);
            foreach ($transPaths as $path) {
                $this->reader->read($path$catalogue);
            }

            if ($domains) {
                foreach ($domains as $domain) {
                    $bag->addCatalogue($this->filterCatalogue($catalogue$domain));
                }
            } else {
                $bag->addCatalogue($catalogue);
            }
        }

        return $bag;
    }

    private function filterCatalogue(MessageCatalogue $catalogue, string $domain): MessageCatalogue
    {
        
$io->title('Translation Messages Extractor and Dumper');
        $io->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale')$currentName));

        $io->comment('Parsing templates...');
        $extractedCatalogue = $this->extractMessages($input->getArgument('locale')$codePaths$input->getOption('prefix'));

        $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.');

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