Waavi / translation

Better translation management for Laravel
MIT License
360 stars 167 forks source link

Class 'UriLocalizer' not found #96

Closed robertnicjoo closed 7 years ago

robertnicjoo commented 7 years ago

I just install this but confuse how to work with it?

I just add

Route::group(['prefix' => \UriLocalizer::localeFromRequest(), 'middleware' => 'localize'], function () {
        Route::get('/', ['uses' => 'PostController@index', 'as' => 'post.index']);
    });

as my homepage and i get error Class 'UriLocalizer' not found how should i run this?

ruidiasbraga commented 7 years ago

same error.

$localizer = \App::make(\Waavi\Translation\UriLocalizer::class);

Route::group(['prefix' => $localizer->localeFromRequest(), 'middleware' => 'localize'], function () { Route::get('/', ['uses' => 'PostController@index', 'as' => 'post.index']); });

seems to solve, but is a really bad practice!!

nickescobedo commented 7 years ago

Did you add UriLocalizaer to the facades array in app.php?

AnasSafi commented 6 years ago

At first add the following alias to your config/app.php aliases:

'aliases'         => [
        /* ... */
        'UriLocalizer'  => Waavi\Translation\Facades\UriLocalizer::class,
    ];

Then you need to clear config cache ... execute this command by cmd:

php artisan cache:clear

if you face this error:

In web.php line 14:

Class 'UriLocalizer' not found

go to your routes and delete line error line ... and re-execute command "php artisan cache:clear" in cmd then return line which you deleted ...