Tanguv0.35.0
Text & i18n16 exports
Raw Markdown

/i18n/context

Dynamic locale scoping and translated message lookup context (t, with-locale) for multilingual applications.

(use /i18n/context)

Structs#

Bundle#

struct

Structured i18n translation bundle with normalized locale catalogs and explicit fallbacks.

FieldTypeDefaultConstraints / Notes
default-localeString——
localesMap——
fallbacksMap——

Constants#

*bundle*#

constant · Any

Active ICU/catalog translation bundle dynamically scoped via `let-ds`.

Value:none

*locale*#

constant · Any

Active BCP 47 locale tag dynamically scoped via `let-ds` (default `"en"`).

Value:"en"

Functions & symbols#

Bundle-construct#

constructor
(Bundle-construct input ...rest)

Constructs a normalized `Bundle` from `{:en {...} :el {...}}` (plus optional opts) or `{:default-locale "en" :locales {...} :fallbacks {...}}`.

ParameterTypeOptionalDescription
inputAnyrequired—
restAnyoptional—
Returns:Any

clear-registered-bundles!#

function
(clear-registered-bundles!)

Clears all entries from the global bundle registry (intended for isolated test suites).

Returns:Any

current-bundle#

function
(current-bundle)

Returns the currently bound translation bundle from dynamic scope (or ()).

Returns:Any

current-language#

function
(current-language)

Returns the normalized lowercase base language subtag (e.g. "el-GR" -> "el").

Returns:Any

current-locale#

function
(current-locale)

Returns the active locale tag from dynamic scope, defaulting to "en".

Returns:Any

localize-field#

function
(localize-field entity field ...rest)

Resolves a localized field from a domain entity (`entity:names`, `entity:field` map, `field-<lang>`, or fallback string).

ParameterTypeOptionalDescription
entityAnyrequired—
fieldAnyrequired—
restAnyoptional—
Returns:Any

register-bundle#

function
(register-bundle ns bundle)

Registers a `Bundle` under namespace `ns` (overwriting any existing entry for `ns`) and returns it.

ParameterTypeOptionalDescription
nsAnyrequired—
bundleAnyrequired—
Returns:Any

registered-bundle#

function
(registered-bundle ns)

Looks up a previously registered `Bundle` by namespace `ns` (returns `()` if unregistered).

ParameterTypeOptionalDescription
nsAnyrequired—
Returns:Any

t#

function
(t key ...rest)

Translates `key` against registered `:ns/key` bundles or dynamic `*bundle*` and `*locale*`.

ParameterTypeOptionalDescription
keyAnyrequired—
restAnyoptional—
Returns:Any

t-html#

function
(t-html key ...rest)

Renders a translation message into an `#html`-spliceable fragment Array preserving structured HTML params.

ParameterTypeOptionalDescription
keyAnyrequired—
restAnyoptional—
Returns:Any

unregister-bundle#

function
(unregister-bundle ns)

Removes any registered bundle for namespace `ns`.

ParameterTypeOptionalDescription
nsAnyrequired—
Returns:Any

validate-bundle#

function
(validate-bundle bundle)

Validates locale parity across all keys, plural `:other` fallbacks, and `{var}` placeholders.

ParameterTypeOptionalDescription
bundleAnyrequired—
Returns:Any

validate-registered-bundles#

function
(validate-registered-bundles)

Validates all currently registered bundles with `validate-bundle` and aggregates parity reports.

Returns:Any