Skip to content

Commit 6ac8ce4

Browse files
author
MBriedis
committed
Fix case when scanning a file for single domain, but only other strings exist.
1 parent 207719c commit 6ac8ce4

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/Utils/FunctionsScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function saveGettextFunctions($translations, array $options)
7070
continue;
7171
}
7272

73-
if (!$isDefaultDomain && !$domainTranslations) {
73+
if (!$domainTranslations) {
7474
continue;
7575
}
7676

tests/AssetsTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ public function testVueJs2MultipleDomainScanning()
548548
}
549549
}
550550

551+
public function testMissingDomainScanWithOtherStringsInFile()
552+
{
553+
$translations = (new Translations())->setDomain('unknown-domain');
554+
555+
PhpCode::fromFileMultiple(static::asset('phpcode6/input.php'), [$translations]);
556+
557+
self::assertCount(0, $translations);
558+
}
559+
551560
public function testXliffUnitIds()
552561
{
553562
$translations = static::get('xliff/Xliff', 'Xliff', ['unitid_as_id' => true]);
@@ -580,6 +589,6 @@ public function testXliffUnitIds()
580589

581590
// Converting from an XLIFF that contains duplicate <source> elements
582591
// to a PO file will result in the loss of the duplicates.
583-
$this->runTestFormat('xliff/Po', $countTranslations-1, $countTranslated-1, $countHeaders);
592+
$this->runTestFormat('xliff/Po', $countTranslations - 1, $countTranslated - 1, $countHeaders);
584593
}
585594
}

tests/assets/phpcode6/input.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
pgettext('context', 'Text with context');
4+
_('No domain text');
5+
6+
dgettext('other', 'Other domain text');

0 commit comments

Comments
 (0)