Closed ptaoussanis closed 7 years ago
I would like to have that as it is something that I added myself. Also my middleware reads the accept-language header from the request. You can find it here: https://github.com/sveri/getless-clj/blob/08f02a63b0d90ef6b78588d1e4b303f93ff45ec3/src/clj/de/sveri/getless/middleware.clj#L25
(defn add-locale [handler]
(fn [req]
(let [accept-language (get-in req [:headers "accept-language"])
short-lang (cond
(.contains accept-language "de") "de"
:else "en")]
(handler (assoc req :localize (partial tr
{:default-locale :en
:dict loc/local-dict}
[(keyword short-lang)]))))))
It is very simple and only for my current needs. There should be a better parser of course.
Hi @sveri, this was added to Tempura some time ago: https://github.com/ptaoussanis/tempura/blob/fbb6cfde7ecff25e5d4a6543565752df59871a21/src/taoensso/tempura.cljc#L314
Hope that helps?
Cheers! :-)
Awesome, I did not see that function, should have looked at the other issues first. Thanks :-)
No problem, appreciate you checking about this :-)
i.e. parse HTTP "accept-language", etc.
Please ping if there's demand, and I'll try get this added.