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