Pure translation functions for the i18n module.
FC/IS rule: PURE functions only — no I/O, no logging, no exceptions.
Translation key resolution order (locale chain):
Marker syntax: [:t :key] — simple lookup [:t :key {:param val}] — with interpolation params [:t :key {:n 3} 3] — plural form (count as 4th arg)
Pure translation functions for the i18n module.
FC/IS rule: PURE functions only — no I/O, no logging, no exceptions.
Translation key resolution order (locale chain):
1. User locale (e.g. :nl)
2. Tenant locale (e.g. :nl)
3. Default locale (:en)
4. Fallback: (str key) for graceful degradation
Marker syntax:
[:t :key] — simple lookup
[:t :key {:param val}] — with interpolation params
[:t :key {:n 3} 3] — plural form (count as 4th arg)Protocol definitions for the i18n module.
FC/IS rule: protocols are interfaces — no implementation here. Adapters (shell layer) implement these protocols.
Protocol definitions for the i18n module. FC/IS rule: protocols are interfaces — no implementation here. Adapters (shell layer) implement these protocols.
Malli validation schemas for the i18n module.
Malli validation schemas for the i18n module.
Translation catalogue loading from classpath EDN resources.
SHELL FUNCTION: performs I/O (classpath resource loading).
The catalogue is a nested map: {locale-keyword {translation-key string-or-plural-map}}
Example: {:en {:user/sign-in "Sign in" :user/greeting {:one "Hello {name}" :many "Hello everyone"}} :nl {:user/sign-in "Aanmelden" :user/greeting {:one "Hallo {name}" :many "Hallo iedereen"}}}
Translation catalogue loading from classpath EDN resources.
SHELL FUNCTION: performs I/O (classpath resource loading).
The catalogue is a nested map:
{locale-keyword {translation-key string-or-plural-map}}
Example:
{:en {:user/sign-in "Sign in"
:user/greeting {:one "Hello {name}" :many "Hello everyone"}}
:nl {:user/sign-in "Aanmelden"
:user/greeting {:one "Hallo {name}" :many "Hallo iedereen"}}}Ring middleware for i18n — injects locale and translation function into requests.
SHELL FUNCTION: wraps Ring handler (performs I/O boundary).
The middleware stores the catalogue and config on the request so that locale resolution can happen at render time (after authentication middleware has added :user to the request).
Injects into request: :i18n/catalogue - the loaded translation catalogue :i18n/default-locale - configured default locale keyword :i18n/locale-chain - ordered vector of locale keywords, e.g. [:nl :en] :i18n/t - translation function (key params? n?) → string
Ring middleware for i18n — injects locale and translation function into requests. SHELL FUNCTION: wraps Ring handler (performs I/O boundary). The middleware stores the catalogue and config on the request so that locale resolution can happen at render time (after authentication middleware has added :user to the request). Injects into request: :i18n/catalogue - the loaded translation catalogue :i18n/default-locale - configured default locale keyword :i18n/locale-chain - ordered vector of locale keywords, e.g. [:nl :en] :i18n/t - translation function (key params? n?) → string
Integrant wiring for the i18n module.
Config key: :wagoe/i18n
Example (development): :wagoe/i18n {:catalogue-paths ["wagoe/i18n/translations" "my_app/i18n/translations"] :default-locale :en :dev? true}
Example (production): :wagoe/i18n {:catalogue-path "wagoe/i18n/translations" :default-locale :en}
Integrant wiring for the i18n module.
Config key: :wagoe/i18n
Example (development):
:wagoe/i18n {:catalogue-paths ["wagoe/i18n/translations"
"my_app/i18n/translations"]
:default-locale :en
:dev? true}
Example (production):
:wagoe/i18n {:catalogue-path "wagoe/i18n/translations"
:default-locale :en}No vars found in this namespace.
Hiccup renderer that resolves [:t ...] markers to strings.
SHELL FUNCTION: calls hiccup2.core/html (I/O boundary for HTML output).
Marker syntax: [:t :key] → (t-fn :key) [:t :key {:param val}] → (t-fn :key {:param val}) [:t :key {:n 3} 3] → (t-fn :key {:n 3} 3) [:t :key nil 3] → (t-fn :key {} 3)
Dev mode wraps each resolved marker in: [:span {:data-i18n (str key)} translated-string]
Hiccup renderer that resolves [:t ...] markers to strings.
SHELL FUNCTION: calls hiccup2.core/html (I/O boundary for HTML output).
Marker syntax:
[:t :key] → (t-fn :key)
[:t :key {:param val}] → (t-fn :key {:param val})
[:t :key {:n 3} 3] → (t-fn :key {:n 3} 3)
[:t :key nil 3] → (t-fn :key {} 3)
Dev mode wraps each resolved marker in:
[:span {:data-i18n (str key)} translated-string]cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |