taoensso / tower

i18n & L10n library for Clojure/Script
https://www.taoensso.com/tower
Eclipse Public License 1.0
278 stars 24 forks source link

Best way to make dynamic paths #68

Open nidu opened 8 years ago

nidu commented 8 years ago

Hello,

Excuse me, but it's not clear to me how can i quickly make dynamic paths, could you please show some example?

For example i have resource lie {:a {:b {:c "Hello"} :d {:c "world"}}. I'd like extract path for either b or d giving this key as an argument. It would be nice to do something like (t :en :a variable :c) instead of (keyword (str "a/" (name variable) "/c")).

Thanks in advance.

ptaoussanis commented 8 years ago

Hi Nikolay,

As you're doing now is fine. Otherwise, if you prefer you can use:

(require '[taoensso.encore :as encore :refer [merge-keywords]])
(merge-keywords [:a :b :c :d]) ; => :a.b.c/d

Tower uses encore, so you'll already have this dependency loaded. Does that help?

nidu commented 8 years ago

Peter, thanks, that's just what i need! Probably it would be nice to mention this approach in readme since making dynamic paths is a common task (as for me) and encore is already shipped.