8000 Fixed #34713 Move new messages to intl domain when possible · symfony/symfony@9ca8720 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ca8720

Browse files
committed
Fixed #34713 Move new messages to intl domain when possible
1 parent 56e79fe commit 9ca8720

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Translation\Catalogue\TargetOperation;
2424
use Symfony\Component\Translation\Extractor\ExtractorInterface;
2525
use Symfony\Component\Translation\MessageCatalogue;
26+
use Symfony\Component\Translation\MessageCatalogueInterface;
2627
use Symfony\Component\Translation\Reader\TranslationReaderInterface;
2728
use Symfony\Component\Translation\Writer\TranslationWriterInterface;
2829

@@ -254,6 +255,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int
254255

255256
$resultMessage = 'Translation files were successfully updated';
256257

258+
// move new messages to intl domain when possible
259+
if (class_exists(\MessageFormatter::class)) {
260+
foreach ($operation->getDomains() as $domain) {
261+
$intlDomain = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX;
262+
$newMessages = $operation->getNewMessages($domain);
263+
264+
if ([] === $newMessages || ([] === $currentCatalogue->all($intlDomain) && [] !== $currentCatalogue->all($domain))) {
265+
continue;
266+
}
267+
268+
$result = $operation->getResult();
269+
$allIntlMessages = $result->all($intlDomain);
270+
$currentMessages = array_diff_key($newMessages, $result->all($domain));
271+
$result->replace($currentMessages, $domain);
272+
$result->replace($allIntlMessages + $newMessages, $intlDomain);
273+
}
274+
}
275+
257276
// show compiled list of messages
258277
if (true === $input->getOption('dump-messages')) {
259278
$extractedMessagesCount = 0;

0 commit comments

Comments
 (0)
0