Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12b311d

Browse filesBrowse files
committed
Filter out trans paths that are covered by a parent folder path
1 parent 97e4212 commit 12b311d
Copy full SHA for 12b311d

File tree

Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2222
use Symfony\Component\Console\Output\OutputInterface;
2323
use Symfony\Component\Console\Style\SymfonyStyle;
24+
use Symfony\Component\Filesystem\Path;
2425
use Symfony\Component\HttpKernel\KernelInterface;
2526
use Symfony\Component\Translation\Catalogue\MergeOperation;
2627
use Symfony\Component\Translation\Catalogue\TargetOperation;
@@ -407,6 +408,7 @@ private function extractMessages(string $locale, array $transPaths, string $pref
407408
{
408409
$extractedCatalogue = new MessageCatalogue($locale);
409410
$this->extractor->setPrefix($prefix);
411+
$transPaths = $this->filterDuplicateTransPaths($transPaths);
410412
foreach ($transPaths as $path) {
411413
if (is_dir($path) || is_file($path)) {
412414
$this->extractor->extract($path, $extractedCatalogue);
@@ -416,6 +418,31 @@ private function extractMessages(string $locale, array $transPaths, string $pref
416418
return $extractedCatalogue;
417419
}
418420

421+
private function filterDuplicateTransPaths(array $transPaths): array
422+
{
423+
foreach ($transPaths as $index => $path) {
424+
if (is_dir($path) || is_file($path)) {
425+
$transPaths[$index] = realpath($path);
426+
}
427+
}
428+
429+
sort($transPaths);
430+
431+
$filteredPaths = [];
432+
433+
foreach ($transPaths as $path) {
434+
foreach ($filteredPaths as $filteredPath) {
435+
if (is_dir($filteredPath) && Path::isBasePath($filteredPath, $path)) {
436+
continue 2;
437+
}
438+
}
439+
440+
$filteredPaths[] = $path;
441+
}
442+
443+
return $filteredPaths;
444+
}
445+
419446
private function loadCurrentMessages(string $locale, array $transPaths): MessageCatalogue
420447
{
421448
$currentCatalogue = new MessageCatalogue($locale);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.