Malachi.I18n (malachi v0.22.7)

View Source

Internationalization module for Malachi. Supports Brazilian Portuguese (pt_BR) and American English (en_US).

Configuration

config :malachi, :locale, "pt_BR"  # or "en_US"

Usage

Malachi.I18n.t(:metrics_started)
Malachi.I18n.t(:transport_enabled, transport: "TLS", port: 4040)

Summary

Functions

Lists all available locales.

Lists all translation keys.

Returns the current locale.

Sets the locale at runtime.

Translates a key with optional interpolation.

Functions

available_locales()

@spec available_locales() :: [String.t()]

Lists all available locales.

keys()

@spec keys() :: [atom()]

Lists all translation keys.

locale()

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

Returns the current locale.

set_locale(new_locale)

@spec set_locale(String.t()) :: :ok

Sets the locale at runtime.

t(key, bindings \\ [])

@spec t(
  atom(),
  keyword()
) :: String.t()

Translates a key with optional interpolation.

Examples

iex> Malachi.I18n.t(:metrics_started)
"✅ Metrics system started"

iex> Malachi.I18n.t(:transport_enabled, transport: "TLS", port: 4040)
"🔒 TLS transport enabled on port 4040"