Thursday, March 2, 2017

locale in laravel 5.4 returns to the pervious locale after refresh

im learning the multi locale inn laravel 5.4 so i created two files first one in resources/lang/es/greeting.php

<?php

return [

    'hello' => 'hola',

];

and second in resources/lang/en/greeting.php

<?php

return [

    'hello' => 'hola',

];

and i created this route inside web.php

Route::get('/{locale}', function ($locale) {
    App::setLocale($locale);
    return view('index');

});

so when i request this link (localhost:8000/es) it works but when i refresh the page its returns to default locale which is en

and i want it to stay in the new locale so help me please



via E-housma Mardini

Advertisement