Skip to content

Commit 4278493

Browse files
bug #35351 Revert #34797 "Fixed translations file dumper behavior" and fix #34713 (yceruto)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Revert #34797 "Fixed translations file dumper behavior" and fix #34713 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35264 | License | MIT | Doc PR | - Revert symfony/symfony#34797 See also symfony/symfony#35328 It's very likely that the new way will be completely different from this one that is being reverted. That's why I'm reverting rather than fixing it. Commits ------- 9ca872054b Fixed #34713 Move new messages to intl domain when possible 56e79fefa1 Revert "Fixed translations file dumper behavior"
2 parents f6aef34 + 3892263 commit 4278493

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Command/TranslationUpdateCommand.php

+19
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)