8000 [FrameworkBundle][Translations] Fix translation commands by kevin-verschaeve · Pull Request #24590 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Translations] Fix translation commands #24590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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 @@ -113,7 +113,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$kernel = $this->getContainer()->get('kernel');

// Define Root Path to App folder
$transPaths = array($kernel->getRootDir().'/Resources/');
$transPaths = array(
$kernel->getRootDir().'/Resources/',
$kernel->getProjectDir().'/',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one problem here. These paths are used to generate views and translations folders paths (see L275 & L295). With Flex, views is renamed by templates, so translations could be extracted but translation keys used in templates won't be extracted.

#24807 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose you a simple solution in PR.

);

// Override with provided Bundle info
if (null !== $input->getArgument('bundle')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$kernel = $this->getContainer()->get('kernel');

// Define Root Path to App folder
$transPaths = array($kernel->getRootDir().'/Resources/');
$transPaths = array(
$kernel->getRootDir().'/Resources/',
$kernel->getProjectDir().'/',
);
$currentName = 'app folder';

// Override with provided Bundle info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</service>

<service id="translation.loader.yml" class="Symfony\Component\Translation\Loader\YamlFileLoader" public="true">
<tag name="translation.loader" alias="yml" />
<tag name="translation.loader" alias="yaml" legacy-alias="yml" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, is that another bugfix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. It allow to find .yml and .yaml files for translations. I let this in this PR because I think it is part of the command fix

</service>

<service id="translation.loader.xliff" class="Symfony\Component\Translation\Loader\XliffFileLoader" public="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public function testDebugDefaultDirectory()

public function testDebugCustomDirectory()
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
->disableOriginalConstructor()
->getMock();

$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo($this->translationDir))
Expand All @@ -83,7 +86,10 @@ public function testDebugCustomDirectory()
*/
public function testDebugInvalidDirectory()
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
->disableOriginalConstructor()
->getMock();

$kernel->expects($this->once())
->method('getBundle')
->with($this->equalTo('dir'))
Expand Down Expand Up @@ -152,7 +158,10 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
);

if (null === $kernel) {
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
->disableOriginalConstructor()
->getMock();

$kernel
->expects($this->any())
->method('getBundle')
Expand All @@ -167,6 +176,10 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getRootDir')
->will($this->returnValue($this->translationDir));

$kernel
->method('getProjectDir')
->will($this->returnValue($this->translationDir));

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
);

if (null === $kernel) {
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
->disableOriginalConstructor()
->getMock();
$kernel
->expects($this->any())
->method('getBundle')
Expand All @@ -147,6 +149,10 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
->method('getRootDir')
->will($this->returnValue($this->translationDir));

$kernel
->method('getProjectDir')
->will($this->returnValue($this->translationDir));

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
Expand Down
0