Using User Locale for Notifications

Jun 16, 2025

It is considered best practice to send notifications and emails in the recipient's preferred locale. Laravel supports this out of the box through the HasLocalePreference contract, which enables you to easily define a user's locale preference:

 

use Illuminate\Contracts\Translation\HasLocalePreference;

class User extends Model implements HasLocalePreference
{
    /**
     * Get the user's preferred locale.
     */
    public function preferredLocale(): string
    {
        return $this->locale;
    }
}

 

Once you implement the `HasLocalePreference` contract, Laravel will automatically use the preferred locale returned by the `preferredLocale` method when sending notifications and emails.

AI Assistant

Summarize, simplify, and ask questions about this content using your preferred AI provider.

Text Tools

Generate cleaner and easier-to-read versions of this content instantly

Have a Question?

Ask anything related to this content and get a focused AI-generated answer.

0/500
Mahmoud Ramadan
Author

Mahmoud Ramadan

Mahmoud is the creator of Digging Code and a contributor to Laravel since 2020.