mardi 26 février 2019

How to set validation language depending on user type Laravel

I have three user types in my application and if the user type is user, validation messages should be English, otherwise if admin or a company, it should be Japanese.

In my app.php file I do:

'locale' => 'en',
'fallback_locale' => 'ja',

And in my web.php file:

Route::group(['middleware' => 'auth:user'], function () {
    App::setLocale('en');
    //user controllers
});

Route::group(['middleware' => 'auth:company'], function () {
    App::setLocale('ja');
    //company controllers
});

Route::group(['middleware' => 'auth:admin'], function () {
    App::setLocale('en');
    //admin controllers
});

When I didn't set the locale language of admin to ja, validation of user is English and the same with the admin and company. Now I set locale of admin and company to ja, the validation messages of users are now also Japanese. This is the validation files languages directory.

enter image description here

I really run out of ideas where to strike this one out and any help is appreciated. I've tried the suggested solutions in the web but nothing is working.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Tmi76U
via IFTTT

Aucun commentaire:

Enregistrer un commentaire