F
Filament4mo ago
Wannes

Translate Database Notifications?

Hi, is it possible to translate the database notifications? Especially if they are ran through a job. For example the new Export Action, which does this:
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Uw contacten export is voltooid en ' . number_format($export->successful_rows) . ' ' . trans_choice('general.row', $export->successful_rows) . ' werden geëxporteerd.';

if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . trans_choice('general.row', $failedRowsCount) . ' werden niet geëxporteerd.';
}
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Uw contacten export is voltooid en ' . number_format($export->successful_rows) . ' ' . trans_choice('general.row', $export->successful_rows) . ' werden geëxporteerd.';

if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . trans_choice('general.row', $failedRowsCount) . ' werden niet geëxporteerd.';
}
}
That text needs to be translated in Dutch, French and English. However in the database notifications table, I don't see a way how to make it translatable. Also in the redis itself I can't retrieve
app()->getLocale()
app()->getLocale()
because it always return the default locale. So I can't just handle it from there. Since notifications are user based, I'm fine to just push the translatable strings to the database, but I can't seem to figure out how to access the user his locale in a Redis Job.
0 Replies
No replies yetBe the first to reply to this messageJoin