Declares, once per Ash domain, how its action errors are translated.

defmodule MyApp.Shop do
  use Ash.Domain, extensions: [AshGettext.Domain]

  gettext do
    backend MyApp.Gettext
    default_locale "en"
    text_domain "ash"
    locale_resolver MyApp.Locale
  end

  resources do
    resource MyApp.Shop.Order
  end
end

Configuration lives here rather than in config.exs on purpose. Ash configures through DSL and passes request-scoped data through action context; global application env would be process-wide mutable state, which forces Application.put_env in tests and rules out async: true. Everything here is read back through AshGettext.Info.

The supported locale list is deliberately not an option — it is derived from the backend via AshGettext.known_locales/1, so it cannot drift from the catalogs actually on disk.

Repeating this block across many domains is avoided the same way Ash avoids it elsewhere: put it in a base domain macro and use that instead.

gettext

Configure how the errors of this domain's actions are translated.

Examples

gettext do
  backend MyApp.Gettext
  default_locale "en"
  text_domain "ash"
end

Options

NameTypeDefaultDocs
backendatomThe Gettext backend whose catalogs this domain translates against.
locale_resolvermoduleRequired. A module implementing AshGettext.Locale.Resolver. It reads the language from the action's actor. With no actor, Gettext's current process language is used.
default_localeString.t"en"The locale used when the resolver names a language the catalogs do not have.
text_domainString.t"ash"The gettext text domain for everything Ash-derived: errors, enum labels, attribute names.
translate_errors?booleantrueWhether resources in this domain translate their action errors.
require_resource_extension?booleanfalseWhen true, compiling the domain reports every resource in its resources block that lacks the AshGettext.Resource extension (a compiler warning, an error under --warnings-as-errors). Off by default on purpose: Ash extensions are opted into, never imposed.