Reputation: 13214
Using the following package: laravel-localization .
I am translating the routes and followed the steps, they all work fine for routes without variables, but i'm stuck on how i should send my variables inside my views.
Link inside my view :
<a href="{{ LaravelLocalization::localizeURL(trans('routes.account-edit')) }}"> Edit Link</a>
routes.php files inside Lang/fr & Lang/nl
<?php
return [
'account-edit' => "account/wijzig-gegevens/{id}",
];
<?php
return [
'account-edit' => "donnees/modifier-donnees/{id}",
];
Laravel routes file:
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => ['localize','localeSessionRedirect', 'localizationRedirect' ]
], function()
{
Route::get(LaravelLocalization::transRoute('routes.account-edit'),'AccountController@edit');
});
I tried just adding it inside the route as array like below, but i can't get it working.
<a href="{{ LaravelLocalization::localizeURL(trans('routes.account-edit'), ['id' => $user->id]) }}"> Edit Link</a>
Upvotes: 1
Views: 2141
Reputation: 14027
Not using the library myself, but according to the code at the github repo, method localizeURL
takes in $url
and $locale
as its parameter, which means that passing in 2nd parameter like you did definitely won't work.
Can you try using method getLocalizedURL
?
LaravelLocalization::getLocalizedURL(null, trans('routes.account-edit'), ['id' => $user->id])
Upvotes: 1