chinleung / laravel-multilingual-routes

A package to handle multilingual routes in your Laravel application.
https://github.com/chinleung/laravel-multilingual-routes-demo
MIT License
394 stars 26 forks source link

Another Question - localized_route #52

Closed Heqma closed 3 years ago

Heqma commented 3 years ago

Hi, i have another Q becouse i have something like this in href "{{ localized_route('front.index') }}" with this controller "Route::multilingual('/', 'FrontController@index')->name('front.index');" and it's work..without pl.front.index but why isn't work with other routes like this?

like: Route::multilingual('/blog/wpis/{slug}', 'BlogController@show')->name('blog.show'); href ="{{ localized_route('blog.show') }}"

other problem:

image image image

chinleung commented 3 years ago

@Heqma You are missing the slug parameter for your route. It should be something like this:

{{ localized_route('blog.show', ['slug' => $blog->slug]) }}
Heqma commented 3 years ago

Ok, but it doesnt translate the route and why i need put slug if it is in route?, dont close topics..

chinleung commented 3 years ago

Ok, but it doesnt translate the route and why i need put slug if it is in route?, dont close topics..

Did you add it in your translation files?

resources/lang/pl/routes.php
resources/lang/en/routes.php
Heqma commented 3 years ago

Yes image image

image image - default

chinleung commented 3 years ago

@Heqma You only translated the blog route. There should be another one:

'blog/wpis/{slug}' => '...',

Or you can use a friendly key:

Route::multilingual('show-blog', ...)->name('blog.show');

And then add the following in your routes.php:

'show-blog' => 'blog/wpis/{slug}',
Heqma commented 3 years ago

Oh.. i see.. that how it's works..

chinleung commented 3 years ago

@Heqma Does it work for you now?