Commits

Meikel Brandmeyer  committed 6622723

Rename translate to resource

  • Participants
  • Parent commits b5c0c3d

Comments (0)

Files changed (1)

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

 (def ^{:private true :tag Set} bundle-keys
   (memoize #(.keySet ^ResourceBundle %)))
 
-(defn translate
-  "Translate the given message in the given bundle. A message is a fully
-  qualified keyword. The namespace part of the keyword specifies the bundle.
-  The name part of the keyword is fully looked up as the key in the bundle.
+(defn resource
+  "Look up the given key in the given bundle. A key is a fully qualified
+  keyword. The namespace part of the keyword specifies the bundle. The name
+  part of the keyword is finally looked up as the key in the bundle.
 
   Optionally the bundle might be given explicitly as second argument. In
-  that case the message may also be an unqualified keyword or a string."
-  ([message]
-   {:pre [(keyword? message) (namespace message)]}
-   (let [bundle (-> message namespace munge ResourceBundle/getBundle)]
-     (translate message bundle)))
-  ([message ^ResourceBundle bundle]
-   {:pre [(or (string? message) (keyword? message))]}
-   (let [message (name message)]
-     (when (.contains (bundle-keys bundle) message)
-       (.getString bundle message)))))
+  that case the key may also be an unqualified keyword or a string."
+  ([key]
+   {:pre [(keyword? key) (namespace key)]}
+   (let [bundle (-> key namespace munge ResourceBundle/getBundle)]
+     (resource key bundle)))
+  ([key ^ResourceBundle bundle]
+   {:pre [(or (keyword? key) (string? key))]}
+   (let [key (name key)]
+     (when (.contains (bundle-keys bundle) key)
+       (.getString bundle key)))))