# `VerifiedTranslations.Message`
[🔗](https://github.com/treathealth/verified_translations/blob/v0.1.1/lib/verified_translations/message.ex#L1)

One translation file: `<path>/<domain>/<slug>-<hash>.json` holding the
source text (`"msgid"`) and one key per locale.

The file name is derived from the source text, so finding a message never
requires an index and two branches adding different messages never touch
the same file.

# `bindings`

```elixir
@spec bindings(String.t()) :: [String.t()]
```

Placeholder names (`%{name}`) used in `text`.

# `create`

```elixir
@spec create(Path.t(), String.t()) :: boolean()
```

Atomically creates `path` with `content` unless it exists. Returns true if
written. Parallel compilers never see a partially written file.

# `encode`

Encodes a message deterministically: `msgid` first, then locales sorted.

# `file_name`

```elixir
@spec file_name(String.t(), String.t()) :: String.t()
```

File name for `msgid`: readable slug plus a content hash of `identity`.

# `path`

```elixir
@spec path(Path.t(), String.t(), String.t(), keyword()) :: Path.t()
```

Path of the JSON file for `msgid`.

## Options

  * `:context` - Gettext-style message context (`msgctxt`)
  * `:plural` - `true` for `~t"..."N`, or the source forms map of `tn/2`

# `read`

```elixir
@spec read(Path.t()) :: {:ok, map(), binary()} | {:error, :enoent | String.t()}
```

Reads a message file.

# `sorted_forms`

```elixir
@spec sorted_forms(%{required(String.t()) =&gt; String.t()}) :: [
  {String.t(), String.t()}
]
```

Plural source forms in CLDR order, as `path/4` expects for `tn/2` messages.

# `update!`

```elixir
@spec update!(Path.t(), String.t(), map(), map() | nil) :: :ok
```

Merges `translations` into the file for `msgid`, creating it if missing.
Raises if the existing file is invalid or belongs to another msgid.

`origin` (e.g. `%{"by" => "machine", "model" => "claude-opus-5-5"}`, or `nil`
for human-written) is recorded for every locale in `translations`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
