Created
September 23, 2016 05:12
-
-
Save whamtet/9085204fb6c6489630d7b7b5da58fc9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static load_string = clojure.java.api.Clojure.var('clojure.core', 'load-string') | |
private static localization = load_string.invoke(''' | |
(require '[clojure.java.io :as io]) | |
(defn cljs-resource [path] ;does this work in production? | |
(io/resource (str "META-INF/assets/taipan_reagent/src/" path))) | |
(defn needed-messages [path] | |
(distinct (map second (re-seq #"\\(messages \\"(\\w+?)\\"\\)" (slurp (cljs-resource path)))))) | |
(fn [request application-context path] | |
(let [locale (org.springframework.web.servlet.support.RequestContextUtils/getLocale request)] | |
(pr-str | |
(into {} (map #(vector % (.getMessage application-context (str "my.localized." %) nil locale)) (needed-messages path)))))) | |
''') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment