AshDispatch.Resource.Dsl.Locales (AshDispatch v0.5.1)
View SourceDSL entity struct for resource-level locale configuration.
Defines which locales should have templates generated and serves as the default locale list for all events in the resource.
Usage in Resource DSL
dispatch do
locales ["sv", "en", "no"],
default_locale: "sv",
locale_from: :visitor_locale
event :created, trigger_on: :create do
channels [
[transport: :email, audience: :customer],
[transport: :email, audience: :admin, locale: "sv"]
]
end
endFields
locales- List of locale codes (e.g.,["sv", "en"]). Templates will be generated for each locale when runningmix ash.codegen.default_locale- Fallback locale when none can be determined from the record. Falls back toAshDispatch.Config.default_locale()if not set.locale_from- Atom field name on the resource to read runtime locale from. At dispatch time, this field is read from the record to determine which locale-specific template to render.
Locale Resolution Priority
- Channel-level
locale(static override) - Channel-level
locale_from(dynamic from record) - Event-level
locale_from - Resource-level
locale_from(this config) - Auto-detected common fields:
:visitor_locale,:locale - Config default (
AshDispatch.Config.default_locale())
Template Fallback Chain
When resolving templates, AshDispatch tries these in order:
email.admin.sv.html.heex(variant + locale)email.admin.html.heex(variant only)email.sv.html.heex(locale only)email.html.heex(base template)default.sv.html.heex(default + locale)default.html.heex(ultimate fallback)