Skip to content

Commit 8974bb6

Browse files
committed
filter should be empty when filtering on all domains
1 parent 3efcdd2 commit 8974bb6

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function read(array $domains, array $locales): TranslatorBag
100100
// Loco forbids concurrent requests, so the requests must be synchronous in order to prevent "429 Too Many Requests" errors.
101101
$response = $this->client->request('GET', \sprintf('export/locale/%s.xlf', rawurlencode($locale)), [
102102
'query' => [
103-
'filter' => $domain,
103+
'filter' => '*' !== $domain ? $domain : '',
104104
'status' => $this->restrictToStatus ?? 'translated,blank-translation',
105105
],
106106
'headers' => [

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,7 @@ public static function getResponsesForOneLocaleAndOneDomain(): \Generator
967967
</body>
968968
</file>
969969
</xliff>
970-
XLIFF
971-
,
970+
XLIFF,
972971
$expectedTranslatorBagEn,
973972
];
974973

@@ -997,8 +996,7 @@ public static function getResponsesForOneLocaleAndOneDomain(): \Generator
997996
</body>
998997
</file>
999998
</xliff>
1000-
XLIFF
1001-
,
999+
XLIFF,
10021000
$expectedTranslatorBagFr,
10031001
];
10041002
}
@@ -1049,8 +1047,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
10491047
</body>
10501048
</file>
10511049
</xliff>
1052-
XLIFF
1053-
,
1050+
XLIFF,
10541051
'messages+intl-icu' => <<<'XLIFF'
10551052
<?xml version="1.0" encoding="UTF-8"?>
10561053
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
@@ -1066,8 +1063,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
10661063
</body>
10671064
</file>
10681065
</xliff>
1069-
XLIFF
1070-
,
1066+
XLIFF,
10711067
'validators' => <<<'XLIFF'
10721068
<?xml version="1.0" encoding="UTF-8"?>
10731069
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
@@ -1087,8 +1083,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
10871083
</body>
10881084
</file>
10891085
</xliff>
1090-
XLIFF
1091-
,
1086+
XLIFF,
10921087
],
10931088
'fr' => [
10941089
'messages' => <<<'XLIFF'
@@ -1106,8 +1101,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
11061101
</body>
11071102
</file>
11081103
</xliff>
1109-
XLIFF
1110-
,
1104+
XLIFF,
11111105
'messages+intl-icu' => <<<'XLIFF'
11121106
<?xml version="1.0" encoding="UTF-8"?>
11131107
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
@@ -1123,8 +1117,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
11231117
</body>
11241118
</file>
11251119
</xliff>
1126-
XLIFF
1127-
,
1120+
XLIFF,
11281121
'validators' => <<<'XLIFF'
11291122
<?xml version="1.0" encoding="UTF-8"?>
11301123
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
@@ -1144,8 +1137,7 @@ public static function getResponsesForManyLocalesAndManyDomains(): \Generator
11441137
</body>
11451138
</file>
11461139
</xliff>
1147-
XLIFF
1148-
,
1140+
XLIFF,
11491141
],
11501142
],
11511143
$expectedTranslatorBag,
@@ -1200,4 +1192,32 @@ function (string $method, string $url, array $options = []): ResponseInterface {
12001192

12011193
$this->translatorBag = $provider->read(['messages'], ['de']);
12021194
}
1195+
1196+
public function testReadForAllDomains()
1197+
{
1198+
$loader = $this->getLoader();
1199+
1200+
$loader
1201+
->expects($this->once())
1202+
->method('load')
1203+
->willReturn($this->createMock(MessageCatalogue::class));
1204+
1205+
$provider = self::createProvider(
1206+
new MockHttpClient([
1207+
function (string $method, string $url, array $options = []): ResponseInterface {
1208+
$this->assertSame('GET', $method);
1209+
$this->assertSame('https://localise.biz/api/export/locale/fr.xlf?filter=&status=translated%2Cblank-translation', $url);
1210+
$this->assertSame(['filter' => '', 'status' => 'translated,blank-translation'], $options['query']);
1211+
1212+
return new MockResponse();
1213+
},
1214+
], 'https://localise.biz/api/'),
1215+
$this->getLoader(),
1216+
$this->getLogger(),
1217+
$this->getDefaultLocale(),
1218+
'localise.biz/api/',
1219+
);
1220+
1221+
$this->translatorBag = $provider->read(['*'], ['fr']);
1222+
}
12031223
}

0 commit comments

Comments
 (0)