I have an an abort(404) with a custom error message with translation and word replacement. But the word isn't replaced, instead it's showing the keyword that's supposed to be replaced.
abort(404, __('errors.no-category-of-type'), ['foo' => 'bar']);
And in errors.php
'no-category-of-type' => 'There is no :foo category.',
This returns There is no :foo category.
instead of replacing the keyword.
I'm a bit surprised it's not working as it seems pretty straightforward and I just follow along what normally works fine of separately used language and abort functions.
CodePudding user response:
You need to pass ['foo' => 'bar']
on trans function as a second argument:
abort(404, __('errors.no-category-of-type', ['foo' => 'bar']));