diff --git a/src/Translator.php b/src/Translator.php index e3e0530..31aa71a 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -331,7 +331,7 @@ public function translate( $translated = $this->trans($message, $params, $domain, $locale); if ($this->returnOriginalMessage) { - if (!$this->getCatalogue()->has($message, $domain)) { + if (!$this->getCatalogue($locale)->has($message, $domain)) { return $originalMessage; } } diff --git a/tests/Tests/TranslatorTest.phpt b/tests/Tests/TranslatorTest.phpt index b68101f..04d620a 100644 --- a/tests/Tests/TranslatorTest.phpt +++ b/tests/Tests/TranslatorTest.phpt @@ -213,6 +213,10 @@ final class TranslatorTest extends TestAbstract Assert::same('It\'s a boy!', $translator->translate('baby_gender', ['gender' => 'boy'])); Assert::same('It\'s a girl!', $translator->translate('baby_gender', ['gender' => 'girl'])); Assert::same('It\'s something else!', $translator->translate('baby_gender', ['gender' => 'kibork'])); + + $translator->setLocale('en_US'); + + Assert::same('Přelož', $translator->translate('keyOnlyInCsCz', null, [], 'messages', 'cs_CZ')); } public function test03(): void diff --git a/tests/lang/messages.cs_CZ.neon b/tests/lang/messages.cs_CZ.neon index 8ce8d0d..5732ad1 100644 --- a/tests/lang/messages.cs_CZ.neon +++ b/tests/lang/messages.cs_CZ.neon @@ -1 +1,2 @@ plural: "Kontakt|Kontakty|Hodně kontaktů" +keyOnlyInCsCz: "Přelož"