Skip to content

Commit

Permalink
use null as default value for none translated string, as null default…
Browse files Browse the repository at this point in the history
… back to the key
  • Loading branch information
Bottelet committed Sep 19, 2024
1 parent 72aed23 commit ff17fc0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Finder/MissingKeysFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function extractMissingTranslations(array $foundStrings, array $jsonTr
foreach ($foundStrings as $string) {
$string = stripslashes($string);
if (! array_key_exists($string, $jsonTranslations)) {
$missingTranslations[$string] = $string;
$missingTranslations[$string] = null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Finder/MissingKeysFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public function findMissingTranslationsFindsPersistentKeysFromConfig(): void


#[Test]
public function findMissingTranslatableStringUseKeyAsDefaultValue(): void
public function findMissingTranslatableStringUseNullAsDefaultValue(): void
{
$multiFunctionFile = $this->createTempFile('multiFunction.php', "<?php echo __('da.key.test'); __('a long string');");
$translationFinder = new MissingKeysFinder;

$foundStrings = $translationFinder->findMissingTranslatableStrings([$multiFunctionFile], []);
$this->assertSame(['da.key.test' => 'da.key.test', 'a long string' => 'a long string'], $foundStrings);
$this->assertSame(['da.key.test' => null, 'a long string' => null], $foundStrings);

}
}
6 changes: 3 additions & 3 deletions tests/TranslationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function translationsAreAppendedWhenNotUsingTranslationService(): void
$this->jsonFilePath
);
$this->assertEquals([
'app.title' => 'app.title',
'Something cool ' => 'Something cool ',
'greeting' => 'greeting',
'app.title' => null,
'Something cool ' => null,
'greeting' => null,
], $missingTranslations);
}

Expand Down

0 comments on commit ff17fc0

Please sign in to comment.