F
Filament11mo ago
Patrick

Translate table column value

Can't find it in the docs. I want to display a status badge in table. The name is in english in my database, but i'd like to display the value in Dutch. I'm not sure I can change this. Any suggestions?
Tables\Columns\TextColumn::make('status')
->label('Status')
->badge()
->color(fn(string $state): string => match ($state) {
'accepted' => 'gray',
'finished' => 'success',
'cancelled' => 'warning',
'failed' => 'danger',
})
->sortable(),
Tables\Columns\TextColumn::make('status')
->label('Status')
->badge()
->color(fn(string $state): string => match ($state) {
'accepted' => 'gray',
'finished' => 'success',
'cancelled' => 'warning',
'failed' => 'danger',
})
->sortable(),
2 Replies
bwurtz999
bwurtz99911mo ago
I don't know of a direct way to use a translation, but you can use ->formatStateUsing() and return a translation that way
Patrick
PatrickOP11mo ago
TextColumn::make('status') ->formatStateUsing(fn (string $state): string => __("statuses.{$state}")) Got it thanks!
Want results from more Discord servers?
Add your server