Skip to content

Commit cca9f75

Browse files
committed
double check use of strings and symbols in arg keys
1 parent 834ef39 commit cca9f75

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ email-cnt = {$cnt ->
6363
(i18n/format bundle :email-cnt {"cnt" 1})
6464
=> "1 email"
6565

66-
(i18n/format bundle "email-cnt" {:cnt 2})
66+
(i18n/format bundle 'email-cnt {'cnt 2})
6767
=> "2 emails"
6868
```
6969

@@ -130,8 +130,7 @@ Done in a `.cljc` like this, translations can be tested in a normal clojure repl
130130
(defn tr
131131
([lang resource] (tr lang resource nil))
132132
([lang resource params]
133-
(let [resource (if (vector? resource) resource [resource])
134-
[id fallback] resource]
133+
(let [[id fallback] (if (vector? resource) resource [resource])]
135134
(or (get-translation (get-bundle lang) id params)
136135
;; You can choose to use the fallback directly or use a translation
137136
;; from a different language. Project Fluent's javascript

test/noahtheduke/fluent_test.cljc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ goodbye = Goodbye world!
5959
#?(:clj Exception :cljs js/ReferenceError)
6060
#"Missing expected keys: \$cnt"
6161
(sut/format bundle :email-cnt {}))))
62-
(is (= "Welcome, Noah!"(sut/format bundle :welcome {"user" "Noah"})))
62+
(is (= "Welcome, Noah!" (sut/format bundle :welcome {"user" "Noah"})))
6363
(is (= "0 emails" (sut/format bundle :email-cnt {:cnt 0})))
6464
(is (= "1 email" (sut/format bundle :email-cnt {:cnt 1})))
65-
(is (= "2 emails" (sut/format bundle :email-cnt {:cnt 2})))
66-
(is (= "100 emails" (sut/format bundle :email-cnt {:cnt 100})))
65+
(is (= "2 emails" (sut/format bundle 'email-cnt {'cnt 2})))
66+
(is (= "100 emails" (sut/format bundle "email-cnt" {"cnt" 100})))
6767
(testing "and ignores extra args"
6868
(is (= "1 email" (sut/format bundle :email-cnt {:cnt 1 :extra :arg})))))))

0 commit comments

Comments
 (0)