Contents

System\Classes\MailManager\HasMailLocale

Overview

HasMailLocale resolves the locale for mail messages, translating templates, layouts and partials from stored translations and localized view files.


Protected Properties

protected string|null $renderLocale

renderLocale is the locale used for the current render.


Public Methods

public findLocalizedView()

public findLocalizedView(
    string $view,
    string|null $locale = null
): string|null 

findLocalizedView returns a localized view name resolved from a locale subdirectory (mail.welcome gives mail.fr.welcome), or null when none exists.

public withLocale()

public withLocale(string $locale, Closure(): $callback): TReturn 

Run the callback with the given locale.

Protected Methods

protected applyTranslateContext()

protected applyTranslateContext(
    mixed $model,
    string|null $locale
): void 

applyTranslateContext sets the locale context on a translatable model using the locale key chain, always resetting the context to avoid reusing a stale locale.

protected getMailLocale()

protected getMailLocale(array $data): string|null 

getMailLocale returns the target locale for a mail message, or null when translation is disabled.

protected localizeMailPartial()

protected localizeMailPartial(
    System\Models\MailPartial $partial,
    string $code,
    string|null $locale
): void 

localizeMailPartial applies a locale to a resolved partial, mirroring the template rules where stored translations take precedence over view files.

protected localizeMailTemplate()

protected localizeMailTemplate(
    System\Models\MailTemplate|null $template,
    string $code,
    string|null $locale
): void 

localizeMailTemplate applies a locale to a resolved template, refilling from a localized view file when available and applying stored translations, which take precedence over view files.

protected makeLocalizedViewName()

protected makeLocalizedViewName($view, $locale): string 

makeLocalizedViewName inserts a locale segment before the final view name, preserving any view namespace.