Skip to content

About

Clojure utility library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

facilguide

Clojure utilities for multi-language routing and locale management on Facil.guide. This library provides locale detection from URL paths, localized URL construction, hreflang tag generation, and language switcher data for internationalized web applications.

Facil.guide is a multi-language platform delivering senior-friendly technology guides in five languages: English, Spanish, French, Portuguese, and Italian. These utilities handle the URL routing and SEO markup needed to serve content across all supported locales.

Installation

Add to your project.clj dependencies:

[facilguide "0.1.0"]

Or in deps.edn:

{:deps {facilguide/facilguide {:mvn/version "0.1.0"}}}

Usage

(require '[facilguide.core :as fg])

;; Detect locale from a URL path
(fg/detect-locale "/es/guia/iphone")
;; => :es

(fg/detect-locale "/guides/setup")
;; => :en

;; Build localized URL paths
(fg/localized-path :fr "/guides/iphone")
;; => "/fr/guides/iphone"

(fg/localized-path :en "/guides/iphone")
;; => "/guides/iphone"

;; Generate hreflang tags for SEO
(->> (fg/hreflang-tags "/guides/iphone")
     (map #(str "<link rel=\"" (:rel %) "\" hreflang=\"" (:hreflang %) "\" href=\"" (:href %) "\" />")))
;; => ("<link rel=\"alternate\" hreflang=\"en\" href=\"/guides/iphone\" />"
;;     "<link rel=\"alternate\" hreflang=\"es\" href=\"/es/guides/iphone\" />"
;;     ...)

;; Build language switcher UI data
(fg/locale-switcher-data "/guides/iphone" :fr)
;; => ({:locale :en :name "English" :native "English" :href "/guides/iphone" :active false}
;;     {:locale :fr :name "French" :native "Francais" :href "/fr/guides/iphone" :active true}
;;     ...)

;; Process all locales for a page with threading
(->> (keys fg/locales)
     (map #(fg/localized-path % "/guides/wifi-setup")))
;; => ("/guides/wifi-setup" "/es/guides/wifi-setup" "/fr/guides/wifi-setup" ...)

Locale Registry

Five locales are supported out of the box. English serves as the default with no URL prefix, while Spanish, French, Portuguese, and Italian use their ISO 639-1 codes as path prefixes. The registry includes display names in both English and the native language for building UI components.

Hreflang Tags

The hreflang-tags function generates the complete set of alternate link declarations needed for multi-language SEO, including the x-default entry pointing to the English version. Pass the output directly to your HTML templating layer.

License

Copyright 2026 Facil.guide

Distributed under the MIT License.

About

Clojure utility library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages