taoensso / tempura

Simple text localization library for Clojure/Script
https://www.taoensso.com/tempura
Eclipse Public License 1.0
260 stars 16 forks source link

Why is an empty translation invalid? #21

Closed kaosko closed 6 years ago

kaosko commented 6 years ago

(taoensso.tempura/tr {:dict {:void {:missing ""}}} [:void] [:key]) results in fairly obscure error

ExceptionInfo Invariant violation in taoensso.tempura.impl:53. Test form (enc/nblank? s) failed against input val "". clojure.core/ex-info (core.clj:4617)

At least it should print out the key that failed. But overall, it seems an unnecessary restriction.

ptaoussanis commented 6 years ago

Hi Kalle, thanks for the report- you've identified an edge case, this behaviour is unintended.

(taoensso.tempura/tr {:dict {:void {:missing "foo"}}} [:void] [:key]) ; => "foo" as intended
(taoensso.tempura/tr {:dict {:void {}}}                         [:void] [:key]) ; => nil     as intended
(taoensso.tempura/tr {:dict {:void {:missing ""}}}       [:void] [:key]) ; => would expect "", but is actually throwing

I.e. the particular combination of specifying a blank :missing val was causing an unintended problem.

Fixed in [com.taoensso/tempura "1.2.1"], now on Clojars.