Framework: Empty translation strings return the key

Created on 9 Sep 2020  路  5Comments  路  Source: laravel/framework

  • 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: https://github.com/laravel/framework/commit/02e983e7bf56a7febe9370d4e54d5f2cbf911751

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'));
    }

Most helpful comment

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

https://github.com/laravel/framework/pull/34228

All 5 comments

I may need to note this as a breaking change.

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

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

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

https://github.com/laravel/framework/pull/34228

Awesome, thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

digirew picture digirew  路  3Comments

YannPl picture YannPl  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

kerbylav picture kerbylav  路  3Comments