validation icon indicating copy to clipboard operation
validation copied to clipboard

Package seems to cause translation errors in other packages

Open sanderbaas opened this issue 3 years ago • 5 comments

It seems that this package causes translation errors in Laravel Nova (see this issue https://github.com/laravel/nova-issues/issues/4192).

By calling a translation in a constructor the incorrect locale is set for the App (https://github.com/laravel/nova-issues/issues/4192#issuecomment-1120249039)

I think this is what is happening with this package in the file validation/src/Laravel/ValidationServiceProvider.php.

From the boot() function $this->getErrorMessage() is called and this calls return $this->app['translator']->get('validation::validation.' . $rulename);. (https://github.com/Intervention/validation/blob/master/src/Laravel/ValidationServiceProvider.php#L48)

When I comment this out or replace it with return ''; the translation errors in Laravel Nova disappear.

I am using php8, laravel/framework 9.26.1, laravel/nova 4.13.0, intervention/validation 3.2.0

sanderbaas avatar Aug 31 '22 08:08 sanderbaas

Thanks for reporting.

According to this comment the translation should not be used before setting a current locale. I checked this and noticed the locale is already set when this code runs.

Can't think of an other solution as to pass static text error messages to the Illuminate\Validation\Factory::extend() method, which contradicts the whole translation logic.

Any other thoughts on this?

olivervogel avatar Sep 01 '22 15:09 olivervogel