-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navbar issue with the route bindings #19
Comments
If I do it like this: @foreach(Localization::getSupportedLocales()->toArray() as $locale => $properties)
<li>
<a href="{{ Localization::getLocalizedURL($locale, null, ['firma' => $firma->id]) }}">
{{ $locale }}
</a>
</li>
@endforeach It works.. but it's very unpractically for a language switcher to deliver a variable name. |
Hi @JimLfe, thanks for your feedback. Of course i'm going to fix that. 😄 I'm going to check and test the Stay tuned. Related : mcamara/laravel-localization#268 |
After reading the code (From github repo, i'm far away from my workstation for the time being, i need to test this in real laravel project). So, i found this: The Source : https://github.com/ARCANEDEV/Localization/blob/master/src/Localization.php#L322-L332 Or, i can change the Source :
The problem is, how can we grab the correct value from an object to substitute the wildcard when we're using the route binding ? For example: // resources/lang/en/routes.php
'users-show' => 'users/{user}', // app/Providers/RouteServiceProvider.php
$router->model('user', \App\User::class);
// Note: It can be a model (Eloquent) or a class by using $router->bind() // app/Http/routes.php
Route::transGet('routes.users-show', ['uses' => 'UsersController@show']); The wildcard in My suggestions :
I'm open if there is any suggestions or ideas to improve this. PS : 🇫🇷 French speaker here and i'm not sorry 😜 |
I've a good news for you @JimLfe, I fixed the issue by adding a new contract ( Now you need to make a few changes: 1st : Update the 2nd : Implement the new interface to your model (Or any bindable class in routes), in your case: <?php namespace App;
use Arcanedev\Localization\Contracts\RouteBindable;
class Firma extends \Eloquent implements RouteBindable {
//...
/**
* Get the wildcard value from the class.
*
* @return int|string
*/
public function getWildcardValue()
{
// You can return an id or whatever you want.
// 'slug', 'ref', 'hashed id' or a translated 'slug' for example.
return $this->id;
}
//...
} That's it, you're ready to go. Let me know if this fix your issue. 👍 |
Thanks, this works great. I like the way you fixed it with the interface. |
You're welcome 👍 |
Hi @arcanedev-maroc , Would you help me please in a similar situation?
Route::localizedGroup(function () {
Route::transGet('routes.services', [
'as' => 'services',
'uses' => 'ServicesController@showList',
]);
Route::transGet('routes.service', [
'as' => 'services.show',
'uses' => 'ServicesController@showService',
]);
});
<?php
return [
'services' => 'services',
'service' => 'services/{slug}',
//...
];
<?php
return [
'services' => 'services',
'service' => 'services/{slug}',
//...
]; What I want to know is how to get the
Thank you very much! |
Hi @ionutVizitiu, There is another way to translate your Check this issue: #27 (comment) BTW, your issue is unrelated to this one 😄. Bonne chance 👍 |
Thank you very much! |
I could try out your package as I said.
I like some stuff that you cleaned a bit up from
mcamara/laravel-localization
like thetransGet
,transPost
and also thelocalizedGroup
.But my main Problem still exists.. but a bit different. If I use model binding with named parameter, the localsNavbar returns the Hole Model Object Data in the URL:
EDIT :
But the translation of the Route is right!!
So if you can fix that, I will never go back to the other package ;-)
The text was updated successfully, but these errors were encountered: