# `Narabe.Messages`
[🔗](https://github.com/hattoriai/narabe/blob/v0.1.0/lib/narabe/messages.ex#L1)

The words of the lists, trees and boards: button labels, what a screen
reader hears as items are lifted, moved and dropped, and why a move was
refused.

Numbers come from the browser (`Intl`), in any locale. The words are
here, in English,
Portuguese, Spanish, French, German, Italian, Dutch and Japanese; a
locale with a region (`pt-BR`, `en-GB`) takes the words of its language,
and another language gets English.

Give a list other words with `messages`, a map from the keys of
`keys/0` to the new words, for example to use your own Gettext
translations:

    <.sortable_list id="tasks" items={@tasks} messages={%{"dragHandle" => gettext("Move task")}}>

Or set them for every list in the config:

    config :narabe, messages: %{"fr" => %{"done" => "Terminé"}}

A word may have placeholders in braces (`{n}`, `{label}`), which the
browser fills. The keys that end in `One` and `Other` are the plural
forms of a count, picked with the plural rules of the locale.

# `for_locale`

```elixir
@spec for_locale(String.t(), map()) :: %{required(String.t()) =&gt; String.t()}
```

The words for a locale: the built-in words of its language, then the
words of the config for the locale and for its language, then
`overrides`. Every key has a value (English when a language lacks one).

Raises `ArgumentError` for an override with an unknown key, so that a
typo shows.

## Examples

    iex> Narabe.Messages.for_locale("pt-PT")["done"]
    "Concluído"
    iex> Narabe.Messages.for_locale("sv")["done"]
    "Done"
    iex> Narabe.Messages.for_locale("en", %{"done" => "Finished"})["done"]
    "Finished"

# `keys`

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

Returns the keys of the messages.

## Examples

    iex> "lifted" in Narabe.Messages.keys()
    true

# `language`

```elixir
@spec language(String.t()) :: String.t()
```

The language of a locale: `"pt"` for `"pt-BR"`, `"zh"` for `"zh_Hant"`.

## Examples

    iex> Narabe.Messages.language("pt-BR")
    "pt"

# `languages`

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

Returns the languages with built-in words.

## Examples

    iex> Narabe.Messages.languages()
    ["de", "en", "es", "fr", "it", "ja", "nl", "pt"]

---

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