Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty translation strings return the key #34218

Closed
brendt opened this issue Sep 9, 2020 · 5 comments
Closed

Empty translation strings return the key #34218

brendt opened this issue Sep 9, 2020 · 5 comments

Comments

@brendt
Copy link
Contributor

brendt commented Sep 9, 2020

  • Laravel Version: 8.0
  • PHP Version: 7.4

Description:

I believe that due to a recent change in \Illuminate\Translation\Translator, empty translation keys now also result in the translation key being show, instead of just the empty string.

This commit added an empty check: 02e983e

empty return true when a string is empty, but an empty translation is a valid one. I believe isset should be used.

Steps To Reproduce:

Here's a simple test case taken from https://github.com/spatie/laravel-translation-loader/blob/master/tests/DummyManagerTest.php

    /** @test */
    public function it_can_translate_using_dummy_manager_using_empty_translation_in_db()
    {
        $this->createLanguageLine('file', 'key', ['en' => '']);
        $this->assertSame('', trans('file.key'));
    }
@taylorotwell
Copy link
Member

I may need to note this as a breaking change.

@taylorotwell
Copy link
Member

This seems to be expected behavior given current state of code just needs to be documented.

@JaZo
Copy link
Contributor

JaZo commented Sep 9, 2020

@taylorotwell This also affects Laravel 6 and 7 causing a breaking change there.

driesvints referenced this issue in illuminate/translation Sep 9, 2020
@driesvints
Copy link
Member

We've reverted this and will patch Laravel 6, 7 & 8 soon. Thanks for reporting @brendt.

#34228

@brendt
Copy link
Contributor Author

brendt commented Sep 10, 2020

Awesome, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants