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

Bug with fn-style-args only strings #20

Closed DjebbZ closed 6 years ago

DjebbZ commented 6 years ago

Hello,

When a string to translate contains only a fn-style arg (%1), tempura returns the number 0 instead of the argument.

(tr {:dict {:en {:a "aaa"
                 :b "b %1"
                 :c "%1"}}}
    [:en]
    [:c]
    ["Tempura"])
=> 0

Bug occured inside my a app. I was able to reproduce it in my app and with a fresh clone of tempura, at tag v1.1.2 in a lein repl.

Note: I know that it's a bit silly to have a text to translate where you just have nothing to translate. We happen to have a translation workflow when it can occur that not everything is translated (or translated properly) at one point.

DjebbZ commented 6 years ago

After some exploration, it seems that the function returned by impl/str->vargs-fn always returns 0 for the above mentioned strings:

((impl/str->vargs-fn "%1") ["toto"])
;; => 0

((impl/str->vargs-fn "hello %1") ["world"])
=> "hello world"

Hope this helps fixing the bug.

ptaoussanis commented 6 years ago

Hi Khalid,

Thanks for the clear error report (and for the follow-up)- that does indeed help with debugging. Will investigate and come back to you :+1:

ptaoussanis commented 6 years ago

Fixed with release of [com.taoensso/tempura "1.2.0"] ๐Ÿ‘

DjebbZ commented 6 years ago

Happy to have helped !๐Ÿ‘

Le dim. 11 mars 2018 ร  14:02, Peter Taoussanis notifications@github.com a รฉcrit :

Fixed with release of [com.taoensso/tempura "1.2.0"] ๐Ÿ‘

โ€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ptaoussanis/tempura/issues/20#issuecomment-372113856, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEt3kAevkheean8-5d02TaZvSJDhGyBks5tdSBzgaJpZM4SkCWR .