translate routes in custom plugin

in my custom plugin, i have the web.php file for the routes
Route::group(['middleware' => ['web']], function () {
Route::get('/people', [TeamController::class, 'index'])->name('team.index');
Route::get('/people/{slug}', [MemberController::class, 'show'])->name('people.show');
Route::get('/people/c/{slug?}', [TeamController::class, 'index'])->name('team.show');
});
Route::group(['middleware' => ['web']], function () {
Route::get('/people', [TeamController::class, 'index'])->name('team.index');
Route::get('/people/{slug}', [MemberController::class, 'show'])->name('people.show');
Route::get('/people/c/{slug?}', [TeamController::class, 'index'])->name('team.show');
});
i would like to translate people when i choose another language, for example en: people it: persone i've tried
Route::get(__('polipeople::messages.team'), [TeamController::class, 'index'])->name('team.index');
Route::get(__('polipeople::messages.team'), [TeamController::class, 'index'])->name('team.index');
but i get
Target class [translator] does not exist.
Target class [translator] does not exist.
because Laravel is trying to resolve the __() function before the service container is fully initialized, causing the error 'Target class [translator] does not exist.' any solution or method for this? thanks
1 Reply
Lara Zeus
Lara Zeus2mo ago
I dont think its possible, coz the route will be cached once before the other classes booted like the translation
Want results from more Discord servers?
Add your server