Liking cljdoc? Tell your friends :D

dev.arkaitz.web-base.i18n

Which language to render, per request (SPEC §14). The host gives a Tempura dictionary — its top-level keys are the supported locales — a default locale, and optionally a function returning the request's own preference list (a choice kept in the session, a cookie, a URL prefix). The base puts two things on the request: :wb/tr, Tempura's translate function bound to the preferences, and :wb/locale, the first preference the dictionary actually supports, so <html lang> never names a language the page is not rendered in.

Read from the request every time, never cached per session: the htmx fragment that arrives a second later carries the same headers and must land in the same language.

Which language to render, per request (SPEC §14). The host gives a Tempura
dictionary — its top-level keys are the supported locales — a default
locale, and optionally a function returning the request's own preference
list (a choice kept in the session, a cookie, a URL prefix). The base puts
two things on the request: `:wb/tr`, Tempura's translate function bound to
the preferences, and `:wb/locale`, the first preference the dictionary
actually supports, so `<html lang>` never names a language the page is not
rendered in.

Read from the request every time, never cached per session: the htmx
fragment that arrives a second later carries the same headers and must land
in the same language.
raw docstring

parse-accept-languageclj

(parse-accept-language header)

The header's language tags ordered by descending quality, written order among equals; entries with q=0 or an unparseable q are dropped. A malformed header is a client's business, never an exception: it yields no preference.

The header's language tags ordered by descending quality, written order
among equals; entries with `q=0` or an unparseable q are dropped. A
malformed header is a client's business, never an exception: it yields no
preference.
sourceraw docstring

wrapclj

(wrap handler {:keys [dict default-locale] :as config})

Middleware adding :wb/tr and :wb/locale to every request. Tempura's locale cache is off: it is a global memo keyed by the preference list, and that list comes from the client.

Middleware adding `:wb/tr` and `:wb/locale` to every request. Tempura's
locale cache is off: it is a global memo keyed by the preference list, and
that list comes from the client.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close