setCatalogueMetadata example

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);
            }
        }

        // For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,         // because doing so will drop messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
$encoding = $dom->encoding ? strtoupper($dom->encoding) : null;

        $namespace = 'urn:oasis:names:tc:xliff:document:1.2';
        $xml->registerXPathNamespace('xliff', $namespace);

        foreach ($xml->xpath('//xliff:file') as $file) {
            $fileAttributes = $file->attributes();

            $file->registerXPathNamespace('xliff', $namespace);

            foreach ($file->xpath('.//xliff:prop') as $prop) {
                $catalogue->setCatalogueMetadata($prop->attributes()['prop-type'](string) $prop$domain);
            }

            foreach ($file->xpath('.//xliff:trans-unit') as $translation) {
                $attributes = $translation->attributes();

                if (!(isset($attributes['resname']) || isset($translation->source))) {
                    continue;
                }

                $source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
                // If the xlf file has another encoding specified, try to convert it because
$catalogue = new MessageCatalogue($locale);
                    $previousMessages = $previousCatalogue->all($domain);

                    if (!str_ends_with($domain$catalogue::INTL_DOMAIN_SUFFIX)) {
                        $previousMessages = array_diff_key($previousMessages$previousCatalogue->all($domain.$catalogue::INTL_DOMAIN_SUFFIX));
                    }
                    foreach ($previousMessages as $key => $message) {
                        $catalogue->set($this->retrieveKeyFromId($key$domain)$message$domain);
                    }

                    foreach ($previousCatalogue->getCatalogueMetadata('', $domain) as $key => $value) {
                        $catalogue->setCatalogueMetadata($key$value$domain);
                    }

                    $translatorBag->addCatalogue($catalogue);

                    continue;
                }

                $responseContent = $response->getContent(false);

                if (200 !== $response->getStatusCode()) {
                    throw new ProviderException('Unable to read the Loco response: '.$responseContent$response);
                }
public static function getResponsesForReadWithLastModified(): \Generator
    {
        $lastModifieds = [
            'en' => 'Tue, 16 Nov 2021 11:35:24 GMT',
            'fr' => 'Wed, 17 Nov 2021 11:22:33 GMT',
        ];

        foreach (self::getResponsesForManyLocalesAndManyDomains() as [$locales$domains$responseContents$expectedTranslatorBag]) {
            foreach ($locales as $locale) {
                foreach ($domains as $domain) {
                    $catalogue = $expectedTranslatorBag->getCatalogue($locale);
                    $catalogue->setCatalogueMetadata('last-modified', $lastModifieds[$locale]$domain);
                }
            }

            yield [$locales$domains$responseContents$lastModifieds$expectedTranslatorBag];
        }
    }
}
foreach ($values as $domain => $keys) {
            foreach ($keys as $key => $value) {
                $this->setMetadata($key$value$domain);
            }
        }
    }

    private function addCatalogueMetadata(array $values): void
    {
        foreach ($values as $domain => $keys) {
            foreach ($keys as $key => $value) {
                $this->setCatalogueMetadata($key$value$domain);
            }
        }
    }
}
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);
            }
        }

        foreach ($this->source->all($domain) as $id => $message) {
            $this->messages[$domain]['all'][$id] = $message;
            
Home | Imprint | This part of the site doesn't use cookies.