Skip to content

[Translation] [Crowdin] Use synchronous HTTP requests when reading the Crowdin API #48109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public function read(array $domains, array $locales): TranslatorBag
$fileList = $this->getFileList();

$translatorBag = new TranslatorBag();
$responses = [];

foreach ($domains as $domain) {
$fileId = $this->getFileIdByDomain($fileList, $domain);
Expand All @@ -126,45 +125,36 @@ public function read(array $domains, array $locales): TranslatorBag
$response = $this->downloadSourceFile($fileId);
}

$responses[] = [$response, $locale, $domain];
}
}
if (204 === $response->getStatusCode()) {
$this->logger->error(sprintf('No content in exported file: "%s".', $response->getContent(false)));

/* @var ResponseInterface $response */
$downloads = [];
foreach ($responses as [$response, $locale, $domain]) {
if (204 === $response->getStatusCode()) {
$this->logger->error(sprintf('No content in exported file: "%s".', $response->getContent(false)));
continue;
}

continue;
}
if (200 !== $statusCode = $response->getStatusCode()) {
$this->logger->error(sprintf('Unable to export file: "%s".', $response->getContent(false)));

if (200 !== $statusCode = $response->getStatusCode()) {
$this->logger->error(sprintf('Unable to export file: "%s".', $response->getContent(false)));
if (500 <= $statusCode) {
throw new ProviderException('Unable to export file.', $response);
}

if (500 <= $statusCode) {
throw new ProviderException('Unable to export file.', $response);
continue;
}

continue;
}
$response = $this->client->request('GET', $response->toArray()['data']['url']);

$response = $this->client->request('GET', $response->toArray()['data']['url']);
$downloads[] = [$response, $locale, $domain];
}
if (200 !== $statusCode = $response->getStatusCode()) {
$this->logger->error(sprintf('Unable to download file content: "%s".', $response->getContent(false)));

foreach ($downloads as [$response, $locale, $domain]) {
if (200 !== $statusCode = $response->getStatusCode()) {
$this->logger->error(sprintf('Unable to download file content: "%s".', $response->getContent(false)));
if (500 <= $statusCode) {
throw new ProviderException('Unable to download file content.', $response);
}

if (500 <= $statusCode) {
throw new ProviderException('Unable to download file content.', $response);
continue;
}

continue;
$translatorBag->addCatalogue($this->loader->load($response->getContent(), $locale, $domain));
}

$translatorBag->addCatalogue($this->loader->load($response->getContent(), $locale, $domain));
}

return $translatorBag;
Expand Down