Multi-language routing and locale utilities for Facil.guide. Provides locale detection, localized URL path construction, hreflang tag generation, and a locale registry for internationalized senior-friendly technology guides.
Multi-language routing and locale utilities for Facil.guide. Provides locale detection, localized URL path construction, hreflang tag generation, and a locale registry for internationalized senior-friendly technology guides.
(detect-locale path)Detect the locale from a URL path by checking for a language prefix. Returns the locale keyword if found, or :en as the default.
(detect-locale "/es/guia/iphone") ;; => :es
(detect-locale "/guides/setup") ;; => :en
Detect the locale from a URL path by checking for a language prefix. Returns the locale keyword if found, or :en as the default. (detect-locale "/es/guia/iphone") ;; => :es (detect-locale "/guides/setup") ;; => :en
(hreflang-tags base-path)Generate a sequence of hreflang link tag maps for a given base path. Produces one entry per supported locale plus an x-default for English. Suitable for rendering into HTML head elements.
(hreflang-tags "/guides/iphone") ;; => ({:rel "alternate" :hreflang "en" :href "/guides/iphone"} ;; {:rel "alternate" :hreflang "es" :href "/es/guides/iphone"} ;; ... ;; {:rel "alternate" :hreflang "x-default" :href "/guides/iphone"})
Generate a sequence of hreflang link tag maps for a given base path.
Produces one entry per supported locale plus an x-default for English.
Suitable for rendering into HTML head elements.
(hreflang-tags "/guides/iphone")
;; => ({:rel "alternate" :hreflang "en" :href "/guides/iphone"}
;; {:rel "alternate" :hreflang "es" :href "/es/guides/iphone"}
;; ...
;; {:rel "alternate" :hreflang "x-default" :href "/guides/iphone"})(locale-switcher-data base-path)(locale-switcher-data base-path current-locale)Generate data for a language switcher UI component. Returns a sequence of maps with locale info and the localized URL.
(locale-switcher-data "/guides/iphone") ;; => ({:locale :en :name "English" :native "English" :href "/guides/iphone" :active false} ;; {:locale :es :name "Spanish" :native "Espanol" :href "/es/guides/iphone" :active false} ;; ...)
Generate data for a language switcher UI component.
Returns a sequence of maps with locale info and the localized URL.
(locale-switcher-data "/guides/iphone")
;; => ({:locale :en :name "English" :native "English" :href "/guides/iphone" :active false}
;; {:locale :es :name "Spanish" :native "Espanol" :href "/es/guides/iphone" :active false}
;; ...)Map of supported locales with display name, native name, and hreflang code.
Map of supported locales with display name, native name, and hreflang code.
(localized-path locale base-path)Build a localized URL path for a given locale and base path. English paths have no prefix. Other locales get their prefix prepended. Handles leading slashes correctly.
(localized-path :es "/guides/iphone") ;; => "/es/guides/iphone"
(localized-path :en "/guides/iphone") ;; => "/guides/iphone"
Build a localized URL path for a given locale and base path. English paths have no prefix. Other locales get their prefix prepended. Handles leading slashes correctly. (localized-path :es "/guides/iphone") ;; => "/es/guides/iphone" (localized-path :en "/guides/iphone") ;; => "/guides/iphone"
Set of supported locale codes for fast lookup.
Set of supported locale codes for fast lookup.
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 |