0

I am making a multilingual site on Laravel 9, I have multilingual routes

ru.home
uk.home
en.home

Based on them, the correct locale is displayed, everything works.

But, instead of writing in each template

{{ route(app()->getLocale().'home') }}

I need to change or override the behavior of a function route() (Illuminate\Routing\UrlGenerator)

To be able to transfer locale into a function like this:

route($name, $parameters = [], $absolute = true, $locale = null)

Как правильно это сделать?

  • This would be a very odd approach to a problem Laravel solves very nicely with their built in localization. Instead of having separate views, why not use the language files the framework provides? https://laravel.com/docs/9.x/localization#defining-translation-strings I would also argue modifying the route helper would lead to more changes then your first example if you really want to do it this way. – Rob Fonseca Jul 13 '22 at 00:28
  • You probably did not read my message, I need routes site.com/ (default lang) site.com/ru (Russian lang) – Денис Линник Jul 13 '22 at 11:50
  • I did read your message and nowhere in your message do you even talk about the site URL. This still is all laid out nicely for you in the Laravel docs on how to handle the locale in the URL string and how to use translations https://laravel.com/docs/9.x/localization#configuring-the-locale – Rob Fonseca Jul 15 '22 at 10:18
  • Have you tried making a multilingual site? And if the default locale should not be present in the url? The documentation does not solve problems with the language prefix ! – Денис Линник Jul 15 '22 at 10:37

0 Answers0