8000 [Translation] Fix reading intl-icu domains with LocoProvider by nicolas-grekas · Pull Request #47172 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
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 @@ -123,8 +123,12 @@ public function read(array $domains, array $locales): TranslatorBag
$this->logger->info(sprintf('No modifications found for locale "%s" and domain "%s" in Loco.', $locale, $domain));

$catalogue = new MessageCatalogue($locale);
$previousMessages = $previousCatalogue->all($domain);

foreach ($previousCatalogue->all($domain) as $key => $message) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,17 @@ public function getResponsesForOneLocaleAndOneDomain(): \Generator
$expectedTranslatorBagEn->addCatalogue($arrayLoader->load([
'index.hello' => 'Hello',
'index.greetings' => 'Welcome, {firstname}!',
], 'en'));
], 'en', 'messages+intl-icu'));

yield ['en', 'messages', <<<'XLIFF'
yield ['en', 'messages+intl-icu', <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<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">
<file original="https://localise.biz/user/symfony-translation-provider" source-language="en" datatype="database" tool-id="loco">
<header>
<tool tool-id="loco" tool-name="Loco" tool-version="1.0.25 20201211-1" tool-company="Loco"/>
</header>
<body>
<trans-unit id="loco:5fd89b853ee27904dd6c5f67" resname="index.hello" datatype="plaintext">
<trans-unit id="loco:5fd89b853ee27904dd6c5f67" resname="index.hello" datatype="plaintext" extradata="loco:format=icu">
<source>index.hello</source>
<target state="translated">Hello</target>
</trans-unit>
Expand All @@ -488,17 +488,17 @@ public function getResponsesForOneLocaleAndOneDomain(): \Generator
$expectedTranslatorBagFr->addCatalogue($arrayLoader->load([
'index.hello' => 'Bonjour',
'index.greetings' => 'Bienvenue, {firstname} !',
], 'fr'));
], 'fr', 'messages+intl-icu'));

yield ['fr', 'messages', <<<'XLIFF'
yield ['fr', 'messages+intl-icu', <<<'XLIFF'
<?xml version="1.0" encoding="UTF-8"?>
<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">
<file original="https://localise.biz/user/symfony-translation-provider" source-language="en" datatype="database" tool-id="loco">
<header>
<tool tool-id="loco" tool-name="Loco" tool-version="1.0.25 20201211-1" tool-company="Loco"/>
</header>
<body>
<trans-unit id="loco:5fd89b853ee27904dd6c5f67" resname="index.hello" datatype="plaintext">
<trans-unit id="loco:5fd89b853ee27904dd6c5f67" resname="index.hello" datatype="plaintext" extradata="loco:format=icu">
<source>index.hello</source>
<target state="translated">Bonjour</target>
</trans-unit>
Expand Down
0