简体   繁体   中英

Laravel localization with Voyager admin

I'm making a Laravel website with Voyager admin and now I need to add localization to that website. Voyager includes its own translations table and I'm using it for creating content in multiple languages from backend. But in the frontend routing is not working, I'm getting NotFoundHttpException error. My routes are as following:

Route::group(['prefix' => 'fr'], function()
{
    App::setLocale('fr');
    Route::get('{slug}', 'PageController@show');
    Route::get('posts/{slug}', 'PostsController@show');
    //and so on
});

How can I fix this?

According to the documentation you can go

Route::prefix('admin')->group so

Route::prefix('fr')->group(function()
{
    App::setLocale('fr');
    Route::get('{slug}', 'PageController@show');
    Route::get('posts/{slug}', 'PostsController@show');
    //and so on
});

AND also the order is important.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM