T
T
Tarasovych2017-04-27 01:14:26
Laravel
Tarasovych, 2017-04-27 01:14:26

How to do localization?

I do according to the guide .
If the route is like this:

spoiler
Route::get('setlocale/{locale}', function ($locale) {
    
    if (in_array($locale, \Config::get('app.locales'))) {    
    	Session::put('locale', $locale);                    
    }

    return redirect()->back();                              

});
, then the link for switching the language should be like this?
<a href="setlocale/ru">ru</a>
Based on var_dump, the link "mysite/setlocale/ru"does not change the current localization to ru
upd:
in routes
if (in_array($locale, Config::get('app.locales'))) {
        Session::put('locale', $locale);
        var_dump($locale);die;
    }
returns the required localization prefix
if (in_array($locale, Config::get('app.locales'))) {
        Session::put('locale', $locale);
        var_dump(Session::put('locale', $locale));die;
    }
returns NULL
Is it correct to conclude that the localization prefix arrives correctly, but does not change in the session parameters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-04-27
@Tarasovych

Take the package and don't worry.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question