From 7c54eb678d58fb9ee7f532a5a5842e6f0e1fe4c9 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 9 Sep 2020 17:01:38 +0200 Subject: [PATCH] Revert "fallback to fallback_locale translation when requested translation line is empty (#34136)" (#34228) This reverts commit 02e983e7bf56a7febe9370d4e54d5f2cbf911751. --- src/Illuminate/Translation/Translator.php | 2 +- tests/Translation/TranslationTranslatorTest.php | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Illuminate/Translation/Translator.php b/src/Illuminate/Translation/Translator.php index 46611b6b6bde..0f1606e8493e 100755 --- a/src/Illuminate/Translation/Translator.php +++ b/src/Illuminate/Translation/Translator.php @@ -122,7 +122,7 @@ public function get($key, array $replace = [], $locale = null, $fallback = true) $locales = $fallback ? $this->localeArray($locale) : [$locale]; foreach ($locales as $locale) { - if (! empty($line = $this->getLine( + if (! is_null($line = $this->getLine( $namespace, $group, $locale, $item, $replace ))) { return $line ?? $key; diff --git a/tests/Translation/TranslationTranslatorTest.php b/tests/Translation/TranslationTranslatorTest.php index 021b8b5dcb5d..a660c8e864aa 100755 --- a/tests/Translation/TranslationTranslatorTest.php +++ b/tests/Translation/TranslationTranslatorTest.php @@ -104,17 +104,6 @@ public function testGetMethodProperlyLoadsAndRetrievesItemForFallback() $this->assertSame('foo', $t->get('foo::bar.foo')); } - public function testGetMethodProperlyLoadsAndRetrievesItemForFallbackWhenLineIsEmpty() - { - $t = new Translator($this->getLoader(), 'en'); - $t->setFallback('lv'); - $t->getLoader()->shouldReceive('load')->once()->with('en', '*', '*')->andReturn([]); - $t->getLoader()->shouldReceive('load')->once()->with('en', 'bar', 'foo')->andReturn(['baz' => '']); - $t->getLoader()->shouldReceive('load')->once()->with('lv', 'bar', 'foo')->andReturn(['foo' => 'foo', 'baz' => 'breeze :foo']); - $this->assertSame('breeze bar', $t->get('foo::bar.baz', ['foo' => 'bar'], 'en')); - $this->assertSame('foo', $t->get('foo::bar.foo')); - } - public function testGetMethodProperlyLoadsAndRetrievesItemForGlobalNamespace() { $t = new Translator($this->getLoader(), 'en');