I ended up doing the following:
1) Routes in route.php are dynamically created using the special artisan command. It analyzes all controllers and creates routes for each action in all supported languages. The language string is processed by routes such as Route :: get ('{lang} / customer / login', 'CustomerController @getLogin') β where ('lang', '[az] {2}'). This way, users can simply change the language string and the site will load in the correct language (if supported). Routes for different languages ββlead to the same controller action. For these languages, besides English, I need translations (routes.php in / app / lang).
2) before the filter for those controllers whose actions are translated, set in the constructor. It basically checks the correctness of the language string and replaces it if not. The selected language will be installed in the session.
I hope someone can use it :)
source share