F
Filamentβ€’10mo ago
BuddhaNature

How can I add a locale as a url parameter on a panel?

I tried adding a locale parameter to my code so that instead of this:
public function panel(Panel $panel): Panel
{
return $panel
->id('books')
//
->path('books/');
}
public function panel(Panel $panel): Panel
{
return $panel
->id('books')
//
->path('books/');
}
I have this:
public function panel(Panel $panel): Panel
{
return $panel
->id('books')
//
->path('books/{locale}');
}
public function panel(Panel $panel): Panel
{
return $panel
->id('books')
//
->path('books/{locale}');
}
But that did not work.
Solution:
create a Middleware and register it in filament panel URL::defaults(['local' => 'en']); change en to the lang, if you want to get it from session or user profile or any logic you want...
Jump to solution
5 Replies
Solution
Lara Zeus
Lara Zeusβ€’10mo ago
create a Middleware and register it in filament panel URL::defaults(['local' => 'en']); change en to the lang, if you want to get it from session or user profile or any logic you want I used it like this ->path('{local}/admin')
BuddhaNature
BuddhaNatureOPβ€’10mo ago
in middleware() or authMiddleware()
Lara Zeus
Lara Zeusβ€’10mo ago
middleware test it thoroughly tho since can affect other parts, my app was so simple no tenant or advanced stuff πŸ™‚
BuddhaNature
BuddhaNatureOPβ€’10mo ago
I have a question related to localization, but not directly to this topic. Is there a way to change the label of a button inorder to remove the resource name without using the label() method. It seems useful to have all of the buttons of action translated natively in Filament, but when the resource name is used, the translations get wonkey. For exaple, in English "Create book" is fine, but in panish, "Crear book" is not correct. It would be create to just have the button say "Create" or "Crear," but withut using the lbel method so all the native translations kick in. You have any experence with that?
Lara Zeus
Lara Zeusβ€’9mo ago
this too late, I didnt get a notifications sorry πŸ™‚ most of the component if not all of them have a method configureUsing to add it to any provider and it will apply to all like this: https://github.com/lara-zeus/tartarus/blob/1.x/src/Providers/FilamentPanelProvider.php#L102
GitHub
tartarus/src/Providers/FilamentPanelProvider.php at 1.x Β· lara-zeus...
simple multi tenants with panels. Contribute to lara-zeus/tartarus development by creating an account on GitHub.
Want results from more Discord servers?
Add your server