1. Meikel Brandmeyer
  2. j18n


j18n / src / main / clojure / j18n / core.clj

The default branch has multiple heads

Diff from to

File src/main/clojure/j18n/core.clj

  • Ignore whitespace
     (when-let [nspace (namespace message)]
       (::bundle (meta (the-ns (symbol nspace)))))))
+(def ^{:private true :tag java.util.HashSet} bundle-keys
+  (memoize
+    (fn [^ResourceBundle bundle]
+      (.keySet bundle))))
 (defn translate*
   "Translate the given message in the given bundle. For resolution rules see
   translate. However, if message is a string or an unqualified keyword, the
    (let [bundle @(resolve (message-to-bundle message))]
      (translate* message bundle)))
   ([message ^ResourceBundle bundle]
-   (.getString bundle (name message))))
+   (let [message (name message)]
+     (when (.contains (bundle-keys bundle) message)
+       (.getString bundle (name message))))))
 (defmacro translate
   "Translate the given message. Message may be a qualified or non-qualified