Skip to content

Commit

Permalink
Merge pull request #137 from laminas/2.28.x-merge-up-into-2.29.x_WC08…
Browse files Browse the repository at this point in the history
…pO9E

Merge release 2.28.1 into 2.29.x
  • Loading branch information
gsteel authored Sep 10, 2024
2 parents 9466a35 + d553a9c commit 3e8c7ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ public function getPluginManager()
*/
public function translate($message, $textDomain = 'default', $locale = null)
{
$locale = $locale === '' ? null : $locale;
$locale = $locale ?? $this->getLocale();
$translation = $this->getTranslatedMessage($message, $locale, $textDomain);

Expand Down
13 changes: 13 additions & 0 deletions test/Translator/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,17 @@ public function testNullMessageArgumentShouldReturnAnEmptyString(): void

self::assertEquals('', $this->translator->translate(null));
}

public function testTranslateWithEmptyStringLocale(): void
{
$this->translator->setLocale('en_US');
$this->translator->addTranslationFile(
'phparray',
$this->testFilesDir . '/testarray/translation-more-en_US.php',
'default',
'en_US'
);

self::assertEquals('Message 8 (en)', $this->translator->translate('Message 8', 'default', ''));
}
}

0 comments on commit 3e8c7ad

Please sign in to comment.