taoensso / tower

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

Tower 3.1.0-beta3 with ClojureScript: IllegalArgumentException with tower/dict-compile* #66

Closed giorgio-v closed 9 years ago

giorgio-v commented 9 years ago

I see the stack trace at the bottom of this issue when I try to compile the translations dictionary in ClojureScript.

Sorry for the hyper-long outputs, but I hope they can give some clues.

Environment, setup, etc

I have created a dict.clj under resources with this content (yes, copy&paste just to get started):

 {:dictionary ; Map or named resource containing map
   {:en   {:example {:foo         ":en :example/foo text"
                     :foo_comment "Hello translator, please do x"
                     :bar {:baz ":en :example.bar/baz text"}
                     :greeting "Hello %s, how are you?"
                     :inline-markdown "<tag>**strong**</tag>"
                     :block-markdown* "<tag>**strong**</tag>"
                     :with-exclaim!   "<tag>**strong**</tag>"
                     :with-arguments  "Num %d = %s"
                     :greeting-alias :example/greeting
                     :baz-alias      :example.bar/baz}
           :missing  "|Missing translation: [%1$s %2$s %3$s]|"}
    :en-US {:example {:foo ":en-US :example/foo text"}}
    :de    {:example {:foo ":de :example/foo text"}}
    :ja "test_ja.clj" ; Import locale's map from external resource
    }
   :dev-mode? true ; Set to true for auto dictionary reloading
   :fallback-locale :de}

The relevant parts in the .cljs:

;; ...
[taoensso.tower                 :as tower
             :refer-macros (with-tscope)]
;; ...
(def tconfig
  {:fallback-locale :en
   :compiled-dictionary (tower/dict-compile* "dict.clj")})

Here is the dependencies tree from boot:

dzerk/boot-cljs-repl "0.1.9" :scope "test"]
[adzerk/boot-cljs "0.0-3308-0" :scope "test"]
[adzerk/boot-reload "0.3.1" :scope "test"]
[adzerk/boot-test "1.0.4" :scope "test"]
[buddy "0.6.1" :exclusions [[org.clojure/clojure] [com.taoensso/encore] [org.clojure/tools.reader]]]
├── [buddy/buddy-auth "0.6.1"]
│   └── [funcool/cuerdas "0.6.0"]
├── [buddy/buddy-core "0.6.0"]
│   ├── [commons-codec "1.10"]
│   ├── [org.bouncycastle/bcpkix-jdk15on "1.52"]
│   ├── [org.bouncycastle/bcprov-jdk15on "1.52"]
│   └── [slingshot "0.12.2"]
├── [buddy/buddy-hashers "0.6.0"]
│   └── [clojurewerkz/scrypt "1.2.0"]
│       └── [com.lambdaworks/scrypt "1.4.0"]
└── [buddy/buddy-sign "0.6.1"]
    ├── [cheshire "5.5.0"]
    │   ├── [com.fasterxml.jackson.core/jackson-core "2.5.3"]
    │   ├── [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.5.3"]
    │   ├── [com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.5.3"]
    │   └── [tigris "0.1.1"]
    ├── [clj-time "0.10.0"]
    │   └── [joda-time "2.7"]
    ├── [com.taoensso/nippy "2.9.0"]
    │   ├── [net.jpountz.lz4/lz4 "1.3"]
    │   ├── [org.iq80.snappy/snappy "0.3"]
    │   └── [org.tukaani/xz "1.5"]
    └── [funcool/cats "0.6.1"]
[com.cognitect/transit-clj "0.8.281" :exclusions [[com.fasterxml.jackson.core/jackson-core] [commons-codec]]]
└── [com.cognitect/transit-java "0.8.304"]
    ├── [com.fasterxml.jackson.datatype/jackson-datatype-json-org "2.3.2"]
    │   ├── [com.fasterxml.jackson.core/jackson-databind "2.3.2"]
    │   │   └── [com.fasterxml.jackson.core/jackson-annotations "2.3.0"]
    │   └── [org.json/json "20090211"]
    ├── [org.apache.directory.studio/org.apache.commons.codec "1.8"]
    └── [org.msgpack/msgpack "0.6.10"]
        ├── [com.googlecode.json-simple/json-simple "1.1.1" :exclusions [[junit]]]
        └── [org.javassist/javassist "3.18.1-GA"]
[com.cognitect/transit-cljs "0.8.220" :exclusions [[org.clojure/clojure]]]
└── [com.cognitect/transit-js "0.8.755"]
[com.taoensso/sente "1.6.0" :exclusions [[org.clojure/clojure]]]
├── [com.taoensso/encore "2.4.2"]
└── [org.clojure/tools.reader "0.9.2"]
[com.taoensso/timbre "4.1.0" :exclusions [[org.clojure/clojure] [com.taoensso/encore]]]
└── [io.aviso/pretty "0.1.18"]
[com.taoensso/tower "3.1.0-beta3" :exclusions [[org.clojure/clojure] [com.taoensso/encore] [io.aviso/pretty] [com.taoensso/timbre]]]
└── [markdown-clj "0.9.65"]
[compojure "1.4.0" :exclusions [[org.clojure/clojure] [clj-time] [commons-codec] [org.clojure/tools.reader] [joda-time]]]
├── [clout "2.1.2"]
│   └── [instaparse "1.4.0" :exclusions [[org.clojure/clojure]]]
├── [medley "0.6.0"]
└── [org.clojure/tools.macro "0.1.5"]
[danielsz/boot-environ "0.0.5"]
[environ "1.0.0" :exclusions [[org.clojure/clojure]]]
[hiccup "1.0.5" :exclusions [[org.clojure/clojure]]]
[http-kit "2.1.19" :exclusions [[org.clojure/clojure]]]
[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.58" :exclusions [[org.clojure/clojure] [org.clojure/tools.reader]]]
├── [com.google.javascript/closure-compiler "v20150729"]
│   ├── [args4j "2.0.26"]
│   ├── [com.google.code.findbugs/jsr305 "1.3.9"]
│   ├── [com.google.code.gson/gson "2.2.4"]
│   ├── [com.google.guava/guava "18.0"]
│   ├── [com.google.javascript/closure-compiler-externs "v20150729"]
│   └── [com.google.protobuf/protobuf-java "2.5.0"]
├── [org.clojure/data.json "0.2.6"]
├── [org.clojure/google-closure-library "0.0-20150805-acd8b553"]
│   └── [org.clojure/google-closure-library-third-party "0.0-20150805-acd8b553"]
└── [org.mozilla/rhino "1.7R5"]
[org.clojure/core.async "0.1.346.0-17112a-alpha" :exclusions [[org.clojure/clojure]]]
└── [org.clojure/tools.analyzer.jvm "0.1.0-beta12"]
    ├── [org.clojure/core.memoize "0.5.6"]
    │   └── [org.clojure/core.cache "0.6.3"]
    │       └── [org.clojure/data.priority-map "0.0.2"]
    ├── [org.clojure/tools.analyzer "0.1.0-beta12"]
    └── [org.ow2.asm/asm-all "4.1"]
[org.clojure/test.check "0.7.0" :scope "test" :exclusions [[org.clojure/clojure]]]
[org.danielsz/system "0.1.8" :exclusions [[org.clojure/clojure] [ns-tracker]]]
├── [com.stuartsierra/component "0.2.2"]
│   └── [com.stuartsierra/dependency "0.1.1"]
└── [reloaded.repl "0.1.0"]
    └── [org.clojure/tools.namespace "0.2.4"]
[quiescent "0.2.0-RC2" :exclusions [[org.clojure/data.json] [org.clojure/clojure] [org.clojure/google-closure-library] [org.clojure/clojurescript] [org.mozilla/rhino] [org.clojure/google-closure-library-third-party] [com.google.javascript/closure-compiler-externs] [com.google.guava/guava] [com.google.javascript/closure-compiler] [org.clojure/tools.reader]]]
└── [cljsjs/react-with-addons "0.13.3-0"]
[ring/ring-core "1.4.0" :exclusions [[org.clojure/clojure] [clj-time] [commons-codec] [org.clojure/tools.reader]]]
├── [commons-fileupload "1.3.1"]
├── [commons-io "2.4"]
├── [crypto-equality "1.0.0"]
├── [crypto-random "1.2.0"]
└── [ring/ring-codec "1.0.0"]
[ring/ring-defaults "0.1.5" :exclusions [[org.clojure/clojure] [clj-time] [commons-fileupload] [commons-codec] [org.clojure/tools.reader] [ring/ring-core]]]
├── [javax.servlet/servlet-api "2.5"]
├── [ring/ring-anti-forgery "1.0.0"]
├── [ring/ring-headers "0.1.3"]
└── [ring/ring-ssl "0.2.1"]
[ring/ring-devel "1.4.0" :scope "test" :exclusions [[org.clojure/clojure] [clj-time] [org.clojure/tools.namespace] [commons-codec] [org.clojure/tools.reader] [joda-time]]]
├── [clj-stacktrace "0.2.8" :scope "test"]
└── [ns-tracker "0.3.0" :scope "test"]
    └── [org.clojure/java.classpath "0.2.2" :scope "test"]

Stack trace

java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Boolean
                                               ...                          
                                  clojure.core/seq            core.clj:  137
          taoensso.encore/nested-merge-with/merge2          encore.clj: 1225
                                               ...                          
                               clojure.core/reduce            core.clj: 6514
                 taoensso.encore/nested-merge-with          encore.clj: 1226
                                               ...                          
                           clojure.core/partial/fn            core.clj: 2494
                                               ...                          
                                clojure.core/apply            core.clj:  630
                      taoensso.tower/fn/fn/iter/fn           tower.clj:  543
                                               ...                          
                                 clojure.core/next            core.clj:   64
                         clojure.core.protocols/fn       protocols.clj:  170
                       clojure.core.protocols/fn/G       protocols.clj:   19
                 clojure.core.protocols/seq-reduce       protocols.clj:   31
                         clojure.core.protocols/fn       protocols.clj:  101
                       clojure.core.protocols/fn/G       protocols.clj:   13
                               clojure.core/reduce            core.clj: 6519
                                 clojure.core/into            core.clj: 6600
                              taoensso.tower/fn/fn           tower.clj:  538
                              taoensso.tower/fn/fn           tower.clj:  648
                                               ...                          
                      taoensso.tower/dict-compile*           tower.clj:  656
                                               ...                          
                                clojure.core/apply            core.clj:  634
          cljs.analyzer$macroexpand_1_STAR_.invoke       analyzer.cljc: 2322
                cljs.analyzer$macroexpand_1.invoke       analyzer.cljc: 2362
                  cljs.analyzer$analyze_seq.invoke       analyzer.cljc: 2392
                 cljs.analyzer$analyze_form.invoke       analyzer.cljc: 2503
                cljs.analyzer$analyze_STAR_.invoke       analyzer.cljc: 2550
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2566
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2561
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2560
cljs.analyzer$analyze_map$fn__2045$fn__2046.invoke       analyzer.cljc: 2401
                               clojure.core/map/fn            core.clj: 2624
                                               ...                          
                                  clojure.core/vec            core.clj:  361
         cljs.analyzer$analyze_map$fn__2045.invoke       analyzer.cljc: 2401
                  cljs.analyzer$analyze_map.invoke       analyzer.cljc: 2401
                 cljs.analyzer$analyze_form.invoke       analyzer.cljc: 2504
                cljs.analyzer$analyze_STAR_.invoke       analyzer.cljc: 2550
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2566
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2561
   cljs.analyzer$eval1579$fn__1580$fn__1583.invoke       analyzer.cljc: 1101
            cljs.analyzer$eval1579$fn__1580.invoke       analyzer.cljc: 1100
                                               ...                          
            cljs.analyzer$analyze_seq_STAR_.invoke       analyzer.cljc: 2368
       cljs.analyzer$analyze_seq_STAR__wrap.invoke       analyzer.cljc: 2373
                  cljs.analyzer$analyze_seq.invoke       analyzer.cljc: 2394
                 cljs.analyzer$analyze_form.invoke       analyzer.cljc: 2503
                cljs.analyzer$analyze_STAR_.invoke       analyzer.cljc: 2550
                      cljs.analyzer$analyze.invoke       analyzer.cljc: 2566
  cljs.compiler$compile_file_STAR_$fn__3289.invoke       compiler.cljc: 1125
               cljs.compiler$with_core_cljs.invoke       compiler.cljc: 1053
           cljs.compiler$compile_file_STAR_.invoke       compiler.cljc: 1076
        cljs.compiler$compile_file$fn__3330.invoke       compiler.cljc: 1237
                 cljs.compiler$compile_file.invoke       compiler.cljc: 1216
                         cljs.closure/compile-file         closure.clj:  426
                          cljs.closure/eval3713/fn         closure.clj:  479
                        cljs.closure/eval3665/fn/G         closure.clj:  383
                          cljs.closure/eval3717/fn         closure.clj:  484
                        cljs.closure/eval3665/fn/G         closure.clj:  383
                    cljs.closure/get-compiled-cljs         closure.clj:  548
                    cljs.closure/cljs-dependencies         closure.clj:  619
                     cljs.closure/add-dependencies         closure.clj:  642
                                               ...                          
                                clojure.core/apply            core.clj:  632
                                cljs.closure/build         closure.clj: 1676
                                cljs.closure/build         closure.clj: 1627
                adzerk.boot-cljs.impl/compile-cljs            impl.clj:   55
                                               ...                          
                                clojure.core/apply            core.clj:  630
                             boot.pod/eval-fn-call             pod.clj:  183
                                 boot.pod/call-in*             pod.clj:  190
                                               ...                          
                                 boot.pod/call-in*             pod.clj:  193
                          adzerk.boot-cljs/compile       boot_cljs.clj:   93
              adzerk.boot-cljs/eval485/fn/fn/fn/fn       boot_cljs.clj:  167
                 adzerk.boot-cljs/eval485/fn/fn/fn       boot_cljs.clj:  162
                 adzerk.boot-cljs/eval455/fn/fn/fn       boot_cljs.clj:  109
            adzerk.boot-cljs-repl/eval568/fn/fn/fn  boot_cljs_repl.clj:  137
                    boot.task.built-in/fn/fn/fn/fn        built_in.clj:  277
                    boot.task.built-in/fn/fn/fn/fn        built_in.clj:  274
               adzerk.boot-reload/eval631/fn/fn/fn     boot_reload.clj:   88
               adzerk.boot-reload/eval631/fn/fn/fn     boot_reload.clj:   81
                     system.boot/eval1709/fn/fn/fn            boot.clj:   25
                 adzerk.boot-test/eval265/fn/fn/fn       boot_test.clj:   50
              boot.task.built-in/fn/fn/fn/fn/fn/fn        built_in.clj:  226
                 boot.task.built-in/fn/fn/fn/fn/fn        built_in.clj:  226
                    boot.task.built-in/fn/fn/fn/fn        built_in.clj:  223
        danielsz.boot-environ/eval1510/fn/fn/fn/fn    boot_environ.clj:   15
                       clojure.core/with-redefs-fn            core.clj: 7209
           danielsz.boot-environ/eval1510/fn/fn/fn    boot_environ.clj:   14
                               boot.core/run-tasks            core.clj:  688
                                 boot.core/boot/fn            core.clj:  698
               clojure.core/binding-conveyor-fn/fn            core.clj: 1916
                                               ...                          
ptaoussanis commented 9 years ago

Hi there,

Could you try again without the :ja "test_ja.clj" ; Import locale's map from external resource line?

giorgio-v commented 9 years ago

Nope. :(

Il giorno 11/ago/2015, alle ore 14:56, Peter Taoussanis notifications@github.com ha scritto:

Hi there,

Could you try again without the :ja "test_ja.clj" ; Import locale's map from external resource line?

— Reply to this email directly or view it on GitHub.

ptaoussanis commented 9 years ago

Could you try again with the following in your .clj?:

   {:en   {:example {:foo         ":en :example/foo text"
                     :foo_comment "Hello translator, please do x"
                     :bar {:baz ":en :example.bar/baz text"}
                     :greeting "Hello %s, how are you?"
                     :inline-markdown "<tag>**strong**</tag>"
                     :block-markdown* "<tag>**strong**</tag>"
                     :with-exclaim!   "<tag>**strong**</tag>"
                     :with-arguments  "Num %d = %s"
                     :greeting-alias :example/greeting
                     :baz-alias      :example.bar/baz}
           :missing  "|Missing translation: [%1$s %2$s %3$s]|"}
    :en-US {:example {:foo ":en-US :example/foo text"}}
    :de    {:example {:foo ":de :example/foo text"}}
    }

Your .clj resource is supposed to contain the :dictionary value, not the entire config map. Also make sure you exclude the :ja "test_ja.clj" entry again.

Did that help?

giorgio-v commented 9 years ago

Yep! I am network challenged at the moment with my laptop, so I had to retype the conf by hand, but it works.

Giorgio Valoti

Il giorno 11/ago/2015, alle ore 17:59, Peter Taoussanis notifications@github.com ha scritto:

Could you try again with the following in your .clj?:

{:en {:example {:foo ":en :example/foo text" :foo_comment "Hello translator, please do x" :bar {:baz ":en :example.bar/baz text"} :greeting "Hello %s, how are you?" :inline-markdown "strong" :block-markdown* "strong" :with-exclaim! "strong" :with-arguments "Num %d = %s" :greeting-alias :example/greeting :baz-alias :example.bar/baz} :missing "|Missing translation: [%1$s %2$s %3$s]|"} :en-US {:example {:foo ":en-US :example/foo text"}} :de {:example {:foo ":de :example/foo text"}} } Your .clj resource is supposed to contain the :dictionary value, not the entire config map. Also make sure you exclude the :ja "test_ja.clj" entry again.

Did that help?

— Reply to this email directly or view it on GitHub.

giorgio-v commented 9 years ago

Peter, thanks a lot!

ptaoussanis commented 9 years ago

No problem, good luck! :+1: