<@U04UQ68083H> Quick question. We want to use loca...
# ory-copilot
h
@chilly-king-10285 Quick question. We want to use localized email templates, but don't want to use this via Identity. It should get the local language from the browser and send that along. How should we about this?
c
A message from kapa.ai
Ory Kratos email template localization is designed to use information from the identity object (such as a language trait or metadata) to determine which language template to use when sending emails. The documented approach is to store the user's preferred language in their identity traits or metadata, and then use that value in your templates to select the appropriate language block or sub-template. This is the only method explicitly supported in the knowledge sources for customizing email language selection at send time, as shown in the examples using
.Identity.traits.lang
or
.Identity.metadata_public.lang
within the template logic [Customizing template content for specific users](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#customizing-template-content-for-specific-users). There is no documented way to automatically detect the user's browser language (e.g., via the Accept-Language header) and pass that to the email template system at the time of sending. The email system does not natively receive or process browser headers; it relies on the data present in the identity object or, optionally, in a transient payload if you are triggering flows programmatically and can inject such data [Transient payload in templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#transient-payload-in-templates). If you control the flow initiation (for example, via a custom frontend), you could theoretically pass the detected browser language as a transient payload when starting a self-service flow, and then reference that in your email template using
{{index .TransientPayload "lang"}}
. However, this is not the default or recommended approach, and the documentation does not provide a full end-to-end example for this use case. Summary: - The standard and supported way is to store the language in the identity traits or metadata. - There is no built-in support for passing the browser's language directly to the email template system. - Using transient payloads is a possible workaround if you can inject the language at flow initiation, but this is not explicitly documented as a best practice. If you need this feature, you may want to consider submitting a feature request or reaching out to the Ory team for further guidance, as the current documentation does not cover this scenario in detail.