use App\Filament\Pages\Settings;
use Filament\Navigation\MenuItem;
use Filament\Panel;
use Filament\SpatieLaravelTranslatablePlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->userMenuItems([
MenuItem::make()
->label(__('admin.settings'))
->url('#')
->icon('heroicon-o-cog-6-tooth'),
// ...
])
->plugins([
SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['en', 'es']),
]);
}
lang/en/admin.php:
return ['settings' => 'Settings'];
lang/es/admin.php:
return ['settings' => 'Ajustes'];
Note that the offical doc shows something like ->label('Settings') but I am doing ->label(__('admin.settings')) because my app's user menu should be translatable.
But when the user switches the language to Spanish, it still shows "Settings" (custom user menu items are the only things in my application that are not translated to Spanish, it is still in English language). The Filament native built-in "Logout" user menu item is translated correctly, it's only my CUSTOM menu items that are not being translated at all.
Additional information: I've found a workaround to make it work using closure.
->label(fn (): string => __('admin.settings'))
But I expect it to work using just ->label(__('admin.settings')) without the workaround.
Description
Custom user menu item is not being translated, it is always shown in the app's main language, no matter the user switches to another language.
Steps To Reproduce
I am using filament/spatie-laravel-translatable-plugin.
Provider:
lang/en/admin.php:
lang/es/admin.php:
Note that the offical doc shows something like
->label('Settings')
but I am doing->label(__('admin.settings'))
because my app's user menu should be translatable.But when the user switches the language to Spanish, it still shows "Settings" (custom user menu items are the only things in my application that are not translated to Spanish, it is still in English language). The Filament native built-in "Logout" user menu item is translated correctly, it's only my CUSTOM menu items that are not being translated at all.
Additional information: I've found a workaround to make it work using closure.
But I expect it to work using just
->label(__('admin.settings'))
without the workaround.Example Application
No response
Version of spatie/laravel-permission package:
6.7.0
Version of laravel/framework package:
v10.48.12
PHP version:
8.2.18
Database engine and version:
No response
OS: Windows/Mac/Linux version:
No response