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 |