Permalink
Browse files

better translation and facts

  • Loading branch information...
1 parent 049e975 commit 51f50e615aeb7104fdc1cbf64e2334685f788b0e @logaan committed Sep 22, 2013
Showing with 32 additions and 27 deletions.
  1. +15 −13 README.md
  2. +17 −14 test/vlad/test/readme.clj
View
@@ -59,15 +59,16 @@ convenience.
[:password] "Password"
[:confirmation] "Password Confirmation"})
-(-> (validate signup {:password "!"})
- (assign-name english-field-names)
- (translate-errors english-translate))
+(midje/fact
+ (-> (validate signup {:password "!"})
+ (assign-name english-field-names)
+ (translate-errors english-translate))
-; {[:password] ["Password must be over 6 characters long."
-; "Password must match the pattern [a-zA-Z]."
-; "Password must match the pattern [0-9]."],
-; [:email] ["Email Address is required."],
-; [:name] ["Full Name is required."]}
+ => {[:password] ["Password must be over 6 characters long."
+ "Password must match the pattern [a-zA-Z]."
+ "Password must match the pattern [0-9]."],
+ [:email] ["Email Address is required."],
+ [:name] ["Full Name is required."]})
(def chinese-field-names
{[:name] "姓名"
@@ -79,15 +80,16 @@ convenience.
(defmethod chinese-translate :vlad.validations/present
[{:keys [name]}]
- (format "%s是必需的。" name))
+ (format "必须填写%s" name))
; Other validation translations go here.
-(-> (validate update {:name "Rich"})
- (assign-name chinese-field-names)
- (translate-errors chinese-translate))
+(midje/fact
+ (-> (validate update {:name "Rich"})
+ (assign-name chinese-field-names)
+ (translate-errors chinese-translate))
-; {[:email] ["邮箱是必需的。"]}
+ => {[:email] ["必须填写邮箱"]})
```
## A simple example
@@ -1,5 +1,6 @@
(ns vlad.test.readme
- (:use vlad))
+ (:require [vlad :refer :all]
+ [midje.sweet :as midje]))
(def common
(join (present [:name])
@@ -24,15 +25,16 @@
[:password] "Password"
[:confirmation] "Password Confirmation"})
-(-> (validate signup {:password "!"})
- (assign-name english-field-names)
- (translate-errors english-translate))
+(midje/fact
+ (-> (validate signup {:password "!"})
+ (assign-name english-field-names)
+ (translate-errors english-translate))
-; {[:password] ["Password must be over 6 characters long."
-; "Password must match the pattern [a-zA-Z]."
-; "Password must match the pattern [0-9]."],
-; [:email] ["Email Address is required."],
-; [:name] ["Full Name is required."]}
+ => {[:password] ["Password must be over 6 characters long."
+ "Password must match the pattern [a-zA-Z]."
+ "Password must match the pattern [0-9]."],
+ [:email] ["Email Address is required."],
+ [:name] ["Full Name is required."]})
(def chinese-field-names
{[:name] "姓名"
@@ -44,12 +46,13 @@
(defmethod chinese-translate :vlad.validations/present
[{:keys [name]}]
- (format "%s是必需的。" name))
+ (format "必须填写%s" name))
; Other validation translations go here.
-(-> (validate update {:name "Rich"})
- (assign-name chinese-field-names)
- (translate-errors chinese-translate))
+(midje/fact
+ (-> (validate update {:name "Rich"})
+ (assign-name chinese-field-names)
+ (translate-errors chinese-translate))
-; {[:email] ["邮箱是必需的。"]}
+ => {[:email] ["必须填写邮箱"]})

0 comments on commit 51f50e6

Please sign in to comment.