jeudi 5 décembre 2019

In Laravel 5.8, the trans() function doesn't work when an Exception was thrown

My trans() calls are working normally, except when in an app/Exceptions/Handler.php exception handler. For example I have the following:

public function render($request, Exception $exception) {

    if ($exception instanceof TokenMismatchException){
        Session::flash('messageclass', 'danger');
        Session::flash('message', trans('general.tokenmismatchexception'));
        return redirect()->back();
    }
    // ...
}

In this case, I'm being displayed general.tokenmismatchexception instead of the actual string. I've triple checked and the file and string are actually there.

Any ideas why this happens? Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire