S
S
sawa42016-10-14 12:44:23
Laravel
sawa4, 2016-10-14 12:44:23

How to make route understand Laravel 5.2 language types?

Hello guys!
I
Look, when recovering a password, I send something like:

http://site.com/en/password/reset/db58caadfedf741b05[email protected]name.ru

or
http://site.com/ru/password/reset/db58caadfedf741b05[email protected]name.ru

In routes.php I write like this:
Route::get('{locale}', function ($locale) {
        $languages = ['ru','en'];
        if (in_array($locale, $languages)){
            Session::put('LANG', $locale);
            return Redirect::back();
        }
    });

But this doesn't work for links, if the link has /en/ or /ru/ after the site domain or anywhere else, then a 404 page will be displayed
. Does anyone have any ideas about this?
II
Another such question, there is a choice of language on the authorization form. For example, the Russian language is selected there, and the user has the English system language parameter in the database. How to switch his site to English after authorization?
Do you guys have any ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seriogja, 2016-11-30
@seriogja

Good afternoon!
Everything is out of the box , no need to invent anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question