Skip to content

Instantly share code, notes, and snippets.

@zetafish
Created July 5, 2017 12:53
Show Gist options
  • Save zetafish/baac52da61bcdb73a9754b790aca1164 to your computer and use it in GitHub Desktop.
Save zetafish/baac52da61bcdb73a9754b790aca1164 to your computer and use it in GitHub Desktop.
Locale Example
(ns core
(:import (java.util Locale
Locale$Category
Locale$LanguageRange)))
(def configured-languages
[(Locale. "en") (Locale. "nl") (Locale. "en" "US") (Locale. "fil")])
(def accept-languages
(Locale$LanguageRange/parse "fil,nl;q=0.8,en-GB;q=0.6,en;q=0.4,en-US;q=0.2"))
;; Get the best matching language
(->>
(Locale/filter accept-languages configured-languages)
(first)
(.getLanguage))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment