jeudi 24 décembre 2015

Localization without route prefix doesn't work

I'm using the Laravel docs to implement localization (without the prefix in the url).

Basically I want two links "EN" and "NL". Depending on which link I click, the locale should be changed to that specific language.

I use this links:

<a href="/language/benl">NL</a>
<a href="/language/en">EN</a>

This route:

Route::get('language/{locale}', 'HomeController@setLang');

And this is my HomeController:

class HomeController extends Controller
{

    public function setLang($locale){
        App::setLocale($locale);
        return back();
    }
}

I set my files in resources/lang the way it's explained in the docs. But, the output ( {{ trans('messages.welcome') }} ) isn't translated.

What am I doing wrong? :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire