;; ported-from: src/i18n/index.ts
;;
;; The app's i18n entry: binds the vendored runtime to THIS app's catalogs and
;; namespace and hydrates the static markup at load. The TS-era MsgKey type
;; check is replaced by test/i18n.test.mjs (en key set == ro/hu key sets, plus a
;; byte snapshot of every value). Require this before anything that renders text.
(ns sueta.i18n
(:require [sueta.config :as config]
[sueta.i18n.en :as en]
[sueta.i18n.hu :as hu]
[sueta.i18n.ro :as ro]
[sueta.i18n.runtime :as rt]))
;; Never read, deliberately: the var exists only so its body runs exactly once
;; at namespace load — `defonce` is what makes a hot reload not re-hydrate the
;; static markup. Requiring this namespace IS the initialisation (the TS
;; `import "./i18n"` contract), so an unread private var is the shape, not a
;; leftover.
#_{:clj-kondo/ignore [:unused-private-var]}
(defonce ^:private booted
(do (rt/init-i18n {:ns config/NS
:catalogs {"en" en/catalog "ro" ro/catalog "hu" hu/catalog}})
(rt/hydrate-html js/document)
true))
(def t rt/t)
(def tn rt/tn)
;; Untyped view for injecting into kits (social-kit's `t` option): unknown keys
;; come back as the key itself, which the kit treats as "use built-in". The kits
;; call it with plain JS vars objects — the runtime handles both.
(defn t-kit
([k] (rt/t k nil))
([k vars] (rt/t k vars)))
(def absorb-suite-lang rt/absorb-suite-lang)
(def fmt-date rt/fmt-date)
(def fmt-num rt/fmt-num)
(def fmt-time rt/fmt-time)
(def get-lang rt/get-lang)
(def hydrate-html rt/hydrate-html)
(def lang-picker-el rt/lang-picker-el)
(def on-lang-change rt/on-lang-change)
(def set-lang rt/set-lang)