final static public Var LOCALE = Var.intern(CLOJURE_NS, Symbol.create
("*locale*"), null);
(defn format
"Formats a string using java.lang.String.format, see
java.util.Formatter for format
string syntax"
[fmt & args]
(let [locale (or *locale*
(java.util.Locale/getDefault))]
(String/format locale fmt (to-array args))))
(defn get-locale
([] (or *locale*
(java.util.Locale/getDefault)))
([locale] (cond (isa? java.util.Locale (class locale)) locale
(sequential? locale) (apply get-locale locale)
:else
(let [locale (str locale)
locales (map second (re-seq #"(?:^|_)([a-zA-
Z]*)" locale))]
(if (= 1 (count locales))
(java.util.Locale. locale)
(apply get-locale locales)))))
([lang country] (java.util.Locale. (str lang) (str country)))
([lang country variant] (java.util.Locale. (str lang) (str country)
(str variant))))
(defmacro with-locale
[locale & body]
`(let [l# (get-locale ~locale)]
(binding [*locale* l#]
[EMAIL PROTECTED])))
But I can't compile core.clj when I put get-locale and with-locale
inside it.
> - *locale* (should be set!-able as well),
A set-locale function ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---