F
Filament2mo ago
tuseto

How to translate select values

I am using filament spatie translatable plugin. I have a simple select:
Select::make('unit')
->options([
'gr' => 'g',
'ml' => 'ml',
// 'gr' => 'гр',
// 'ml' => 'мл',
]),
Select::make('unit')
->options([
'gr' => 'g',
'ml' => 'ml',
// 'gr' => 'гр',
// 'ml' => 'мл',
]),
Depending on language saved valued should be translated. How I can achieve that?
1 Reply
tuseto
tusetoOP2mo ago
Some sort of solution
Select::make('unit')
->options(function ($livewire) {
return [
__('dish.gr', [], $livewire->activeLocale) => __('dish.gr', [], $livewire->activeLocale),
__('dish.ml', [], $livewire->activeLocale) => __('dish.ml', [], $livewire->activeLocale),
];
}),
Select::make('unit')
->options(function ($livewire) {
return [
__('dish.gr', [], $livewire->activeLocale) => __('dish.gr', [], $livewire->activeLocale),
__('dish.ml', [], $livewire->activeLocale) => __('dish.ml', [], $livewire->activeLocale),
];
}),
But this way when change the language from the plugin language switcher select becomes empty
Want results from more Discord servers?
Add your server