getCatalogueMetadata example

$xliffFile->setAttribute('source-language', str_replace('_', '-', $defaultLocale));
        $xliffFile->setAttribute('target-language', str_replace('_', '-', $messages->getLocale()));
        $xliffFile->setAttribute('datatype', 'plaintext');
        $xliffFile->setAttribute('original', 'file.ext');

        $xliffHead = $xliffFile->appendChild($dom->createElement('header'));
        $xliffTool = $xliffHead->appendChild($dom->createElement('tool'));
        foreach ($toolInfo as $id => $value) {
            $xliffTool->setAttribute($id$value);
        }

        if ($catalogueMetadata = $messages->getCatalogueMetadata('', $domain) ?? []) {
            $xliffPropGroup = $xliffHead->appendChild($dom->createElement('prop-group'));
            foreach ($catalogueMetadata as $key => $value) {
                $xliffProp = $xliffPropGroup->appendChild($dom->createElement('prop'));
                $xliffProp->setAttribute('prop-type', $key);
                $xliffProp->appendChild($dom->createTextNode($value));
            }
        }

        $xliffBody = $xliffFile->appendChild($dom->createElement('body'));
        foreach ($messages->all($domain) as $source => $target) {
            $translation = $dom->createElement('trans-unit');

            
foreach ($locales as $locale) {
            foreach ($domains as $domain) {
                $previousCatalogue = $this->translatorBag?->getCatalogue($locale);

                // Loco forbids concurrent requests, so the requests must be synchronous in order to prevent "429 Too Many Requests" errors.                 $response = $this->client->request('GET', sprintf('export/locale/%s.xlf', rawurlencode($locale))[
                    'query' => [
                        'filter' => $domain,
                        'status' => 'translated,blank-translation',
                    ],
                    'headers' => [
                        'If-Modified-Since' => $previousCatalogue instanceof CatalogueMetadataAwareInterface ? $previousCatalogue->getCatalogueMetadata('last-modified', $domain) : null,
                    ],
                ]);

                if (404 === $response->getStatusCode()) {
                    $this->logger->warning(sprintf('Locale "%s" for domain "%s" does not exist in Loco.', $locale$domain));
                    continue;
                }

                if (304 === $response->getStatusCode()) {
                    $this->logger->info(sprintf('No modifications found for locale "%s" and domain "%s" in Loco.', $locale$domain));

                    
foreach ($catalogue->getResources() as $resource) {
            $this->addResource($resource);
        }

        if ($catalogue instanceof MetadataAwareInterface) {
            $metadata = $catalogue->getMetadata('', '');
            $this->addMetadata($metadata);
        }

        if ($catalogue instanceof CatalogueMetadataAwareInterface) {
            $catalogueMetadata = $catalogue->getCatalogueMetadata('', '');
            $this->addCatalogueMetadata($catalogueMetadata);
        }
    }

    /** * @return void */
    public function addFallbackCatalogue(MessageCatalogueInterface $catalogue)
    {
        // detect circular references         $c = $catalogue;
        

    protected function processDomain(string $domain)
    {
        $this->messages[$domain] = [
            'all' => [],
            'new' => [],
            'obsolete' => [],
        ];
        $intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;

        foreach ($this->target->getCatalogueMetadata('', $domain) ?? [] as $key => $value) {
            if (null === $this->result->getCatalogueMetadata($key$domain)) {
                $this->result->setCatalogueMetadata($key$value$domain);
            }
        }

        foreach ($this->target->getCatalogueMetadata('', $intlDomain) ?? [] as $key => $value) {
            if (null === $this->result->getCatalogueMetadata($key$intlDomain)) {
                $this->result->setCatalogueMetadata($key$value$intlDomain);
            }
        }

        

    protected function processDomain(string $domain)
    {
        $this->messages[$domain] = [
            'all' => [],
            'new' => [],
            'obsolete' => [],
        ];
        $intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;

        foreach ($this->target->getCatalogueMetadata('', $domain) ?? [] as $key => $value) {
            if (null === $this->result->getCatalogueMetadata($key$domain)) {
                $this->result->setCatalogueMetadata($key$value$domain);
            }
        }

        foreach ($this->target->getCatalogueMetadata('', $intlDomain) ?? [] as $key => $value) {
            if (null === $this->result->getCatalogueMetadata($key$intlDomain)) {
                $this->result->setCatalogueMetadata($key$value$intlDomain);
            }
        }

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