Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 5.4: (21 commits)
  Add missing license header
  [Workflow] Catch error when trying to get an uninitialized marking
  Add missing license header
  Allow usage of Provider domains if possible
  Use reference date in reverse transform Fixes #40997
  Fix env resolution in lock configuration
  Fix Symfony not working on SMB share #45990
  [Messenger] DoctrineTransportFactory works with notify and decorated PostgreSQL driver
  [Cache] make LockRegistry use static properties instead of static variables
  fix: return-path has higher priority for envelope address than from address (fixes #41322)
  [HttpClient] Fix sending content-length when streaming the body
  [Console] Header with column max width is now well wrap with separator
  Fix use_cookies framework session configuration
  [FrameworkBundle] [Command] Fix `debug:router --no-interaction` error …
  [Intl] Update the ICU data to 71.1 - 5.4
  [Intl] Update the ICU data to 71.1 - 4.4
  Add tests to messenger connection get for OraclePlatform
  [RateLimiter] Adding default empty value
  [DependencyInjection] Add TaggedIteratorArgument unit tests
  [Process] Fix Process::getEnv() when setEnv() hasn't been called before
  ...
  • Loading branch information
nicolas-grekas committed Apr 12, 2022
2 parents b2792b3 + 35fdde4 commit 821883b
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Command/TranslationPushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Translation\Provider\FilteringProvider;
use Symfony\Component\Translation\Provider\TranslationProviderCollection;
use Symfony\Component\Translation\Reader\TranslationReaderInterface;
use Symfony\Component\Translation\TranslatorBag;
Expand Down Expand Up @@ -132,7 +133,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths);

if (!$domains) {
$domains = $this->getDomainsFromTranslatorBag($localTranslations);
if ($provider instanceof FilteringProvider) {
$domains = $provider->getDomains();
}

if (!$domains) {
$domains = $this->getDomainsFromTranslatorBag($localTranslations);
}
}

if (!$deleteMissing && $force) {
Expand Down
3 changes: 3 additions & 0 deletions Resources/data/parents.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"en_MS": "en_001",
"en_MT": "en_001",
"en_MU": "en_001",
"en_MV": "en_001",
"en_MW": "en_001",
"en_MY": "en_001",
"en_NA": "en_001",
Expand Down Expand Up @@ -116,6 +117,8 @@
"es_UY": "es_419",
"es_VE": "es_419",
"ff_Adlm": "root",
"hi_Latn": "en_IN",
"ks_Deva": "root",
"nb": "no",
"nn": "no",
"pa_Arab": "root",
Expand Down
64 changes: 64 additions & 0 deletions Tests/Command/TranslationPushCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
use Symfony\Component\Translation\Command\TranslationPushCommand;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Loader\XliffFileLoader;
use Symfony\Component\Translation\Provider\FilteringProvider;
use Symfony\Component\Translation\Provider\ProviderInterface;
use Symfony\Component\Translation\Provider\TranslationProviderCollection;
use Symfony\Component\Translation\Reader\TranslationReader;
use Symfony\Component\Translation\TranslatorBag;

Expand Down Expand Up @@ -259,6 +261,68 @@ public function testPushForceAndDeleteMissingMessages()
$this->assertStringContainsString('[OK] All local translations has been sent to "null" (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
}

public function testPushWithProviderDomains()
{
$arrayLoader = new ArrayLoader();
$xliffLoader = new XliffFileLoader();
$locales = ['en', 'fr'];
$domains = ['messages'];

// Simulate existing messages on Provider
$providerReadTranslatorBag = new TranslatorBag();
$providerReadTranslatorBag->addCatalogue($arrayLoader->load(['note' => 'NOTE'], 'en'));
$providerReadTranslatorBag->addCatalogue($arrayLoader->load(['note' => 'NOTE'], 'fr'));

$provider = $this->createMock(FilteringProvider::class);
$provider->expects($this->once())
->method('read')
->with($domains, $locales)
->willReturn($providerReadTranslatorBag);
$provider->expects($this->once())
->method('getDomains')
->willReturn(['messages']);

$filenameEn = $this->createFile([
'note' => 'NOTE',
'new.foo' => 'newFoo',
]);
$filenameFr = $this->createFile([
'note' => 'NOTE',
'new.foo' => 'nouveauFoo',
], 'fr');
$localTranslatorBag = new TranslatorBag();
$localTranslatorBag->addCatalogue($xliffLoader->load($filenameEn, 'en'));
$localTranslatorBag->addCatalogue($xliffLoader->load($filenameFr, 'fr'));

$provider->expects($this->once())
->method('write')
->with($localTranslatorBag->diff($providerReadTranslatorBag));

$provider->expects($this->once())
->method('__toString')
->willReturn('null://default');

$reader = new TranslationReader();
$reader->addLoader('xlf', new XliffFileLoader());

$command = new TranslationPushCommand(
new TranslationProviderCollection([
'loco' => $provider,
]),
$reader,
[$this->translationAppDir.'/translations'],
$locales
);

$application = new Application();
$application->add($command);
$tester = new CommandTester($application->find('translation:push'));

$tester->execute(['--locales' => ['en', 'fr']]);

$this->assertStringContainsString('[OK] New local translations has been sent to "null" (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
}

/**
* @dataProvider provideCompletionSuggestions
*/
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/fixtures/ControllerArguments.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;

use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/fixtures/ServiceArguments.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;

use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/fixtures/ServiceMethodCalls.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;

use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/fixtures/ServiceProperties.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;

class ServiceProperties
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/fixtures/ServiceSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;

use Psr\Container\ContainerInterface;
Expand Down

0 comments on commit 821883b

Please sign in to comment.