# `ElementorexCms.I18n`
[🔗](https://github.com/rocket4ce/elementorex_cms/blob/v0.1.0/lib/elementorex_cms/i18n.ex#L1)

Translations of the editor interface and the built-in blocks.

Every user-facing string of the library is written in English and looked up
in the dictionary of the current locale when it is rendered. The library ships
Spanish (`"es"`); English is the default.

The locale is per process, like Gettext's: the editor sets it from its
`locale` attribute on every update, so the LiveView that hosts it renders in
that language. Outside the editor use `put_locale/1` or configure a default:

    config :elementorex_cms, locale: "es"

Strings can be added or overridden per locale (for example the labels of your
own blocks, or a whole new language):

    config :elementorex_cms, :translations, %{
      "es" => %{"Pricing table" => "Tabla de precios"},
      "pt" => %{"Button" => "Botão"}
    }

# `locale`

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

Locale of the current process, falling back to the configured default.

# `locales`

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

Locales with a built-in dictionary.

# `put_locale`

```elixir
@spec put_locale(String.t() | atom() | nil) :: String.t() | nil
```

Sets the locale of the current process (`"en"`, `"es"`, ...).

# `t`

```elixir
@spec t(String.t() | nil, keyword() | map()) :: String.t()
```

Translates `text` to the current locale. `bindings` replace `%{name}`
placeholders after the lookup.

    iex> ElementorexCms.I18n.put_locale("es")
    iex> ElementorexCms.I18n.t("Button")
    "Botón"
    iex> ElementorexCms.I18n.t("%{count} items", count: 3)
    "3 elementos"

---

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