As normally with no plugins (jelatelno) enable a multilingual Laravel 5.3?

It's a delusion of some kind. Out of the box is impossible to tie languages to:
  • Opened in url domain.com/en/home and /domain.com/ru/home
  • Worked without additional packages from composer
  • Worked with one route (Route::get()) and group (Route::group())
  • After I agreed to put something fresh (5.2+)

Tell me how to do it?
Basic requirements:
  • Ranting in /domain.com/en/ru
  • Can middleware
  • Working with Route::resource() (if REST does not work)
  • Working with url() helper (screwed twig)
July 2nd 19 at 17:33
2 answers
July 2nd 19 at 17:35
What is a problem mcamara/laravel-localization?

With the exception of the second paragraph of the requirements. ;-)
Thanks for the reply. There is support for 5.2.x. Last time it did not start (or I am inept) - June.Beier89 commented on July 2nd 19 at 17:38
: So - You are satisfied with my offer? :-) - Buddy commented on July 2nd 19 at 17:41
How they work and the generation of ranting from helper url() after all perversions?

By the way, wouldn't start because:
UnsupportedLocaleException in LaravelLocalization.php line 119:
Laravel's default locale is not in the supportedLocales array. - June.Beier89 commented on July 2nd 19 at 17:44
On the first:
mcamara/laravel-localization#helpers

Second:
Uncomment in vendor/mcamara/laraval-localization/src/config/config.php the language You need. - Buddy commented on July 2nd 19 at 17:47
: use the helper route() with EN-Suite URLs. Did today with this plugin, everything works fine on 5.3 - Lincoln.Will commented on July 2nd 19 at 17:50
: What about resource? This is a required item =( - June.Beier89 commented on July 2nd 19 at 17:53
:
Better not to touch anything in vendor/.
Write that it is possible to export the config: https://github.com/mcamara/laravel-localization#co...
Or to register in app/providers/ConfigServicePovider.php
Test resource - June.Beier89 commented on July 2nd 19 at 17:56
: Yes, you could. P. S. P - political correctness, I got the previous message. :-) - Buddy commented on July 2nd 19 at 17:59
: All URLs turned into a mess: en/login?_url=%2Flogin - June.Beier89 commented on July 2nd 19 at 18:02
: Courtesy, the best weapon..))) - June.Beier89 commented on July 2nd 19 at 18:05
: Yes, speak politely, and think as you like)) - Buddy commented on July 2nd 19 at 18:08
Screw it, it works.
But all the AJAX URLs are now of the form: md.dev/en/delete/25?_url=%2Fdelete%2F25
Helper url() is useless and draft dozens of resource controllers and they all now have to call. o_o
Laravel... - June.Beier89 commented on July 2nd 19 at 18:11
After a little testing I realized that this is not suitable option because:

1. All the routes to mush (even ajax for redirect)
2. The resource controllers to generate a link using url() and not using route() cannot be used. - June.Beier89 commented on July 2nd 19 at 18:14
July 2nd 19 at 17:37
As I've done recently:
Routes:
// Route group for locale handling
Route::group(['prefix' => '{locale}', 'middleware' => ['locale']], function () {
 // Home page
 Route::get('/', 'HomeController@index')->name('home');
});

// Middleware
public function handle($request, Closure $next)
{
 // Set the app locale
 $locale = $request->segment(1);

 if($locale && in_array($locale, config('app.locales')))
{
App::setLocale($locale);
}

 return $next($request);
}

// Setting the language
<ul class="dropdown-menu">
the <li>
 <a href="{{ route(Route::currentRouteName(), ['locale' => 'EN']) }}">
Russian
</a>
</li>
the <li>
 <a href="{{ route(Route::currentRouteName(), ['locale' => 'en']) }}">
English
</a>
</li>
</ul>


config('app.locales') - an array containing all the locales your app supports.

Important: in this approach, all Routes must be imenovanie.
Unfortunately, this approach does not allow to call the resource routes. - June.Beier89 commented on July 2nd 19 at 17:40

Find more questions by tags LaravelPHP