Forwarding to the correct language

Need to implement a competent redirect redirect to a page with the correct language.

Ie we have a site:

It has 2 languages: and, respectively.

It is required that when entering the, the language should be correctly selected, and redirected to the appropriate section of the language, the or

also, if the user for some reason switched to the, or the he was also transferred to the corresponding page with the language{ru or en}/news and{ru or en}/news/today respectively

It is also required to save the post request, that is, if there was a request to the, should redirect the{ru or en}?User=1

Multilingualism on the site is implemented, the corresponding language is written in dispatch: beforeExecuteRoute in this way: $ session-> set('lang', $lang);

At the moment, everything has been done with a crutch. If there is no language in the address (ru or en), then we redirect to the controller that determines the language from the session ($ this-> session-> get ('lang');) and then simply transfer it to the corresponding language.

A simpler solution might be to not have separate language-based URLs, and just rely on the SESSION's language value.

So if someone visits with no language set, you either forward them to a controller that determines their language, or you have some code in your base controller that determines it. The second option would be better, because then that functionality could be run on any page, not just the homepage.

Then just build it into your view that you check the language before determining which templates or language files to use.

This will also simplify POST forwarding, which is a pain-in-the-ass.