AshGettext.Domain (AshGettext v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

gettext(body)

(macro)