aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Message
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-08-11 21:32:10 +0200
committerJoris Guyonvarch2015-08-11 21:32:10 +0200
commit892a7dd19a92fc18767984e624b8a5026dce61e4 (patch)
tree7d59d58d96958e91a4e9114be0effb9ec7a082a8 /src/server/Model/Message
parenta3bab4f2a0cc8a6a95753dc91d8e862f40c80dcc (diff)
Showing server sides generated messages from the client
Diffstat (limited to 'src/server/Model/Message')
-rw-r--r--src/server/Model/Message/Key.hs12
-rw-r--r--src/server/Model/Message/Parts.hs23
-rw-r--r--src/server/Model/Message/Translations.hs25
3 files changed, 47 insertions, 13 deletions
diff --git a/src/server/Model/Message/Key.hs b/src/server/Model/Message/Key.hs
index 59a5dbc..e1a382c 100644
--- a/src/server/Model/Message/Key.hs
+++ b/src/server/Model/Message/Key.hs
@@ -4,7 +4,17 @@ module Model.Message.Key
data Key =
- January
+ -- Sign in
+
+ SharedCost
+ | SignIn
+ | SendEmailFail
+ | Unauthorized
+ | EnterValidEmail
+
+ -- Dates
+
+ | January
| February
| March
| April
diff --git a/src/server/Model/Message/Parts.hs b/src/server/Model/Message/Parts.hs
index b7855f8..d065cf2 100644
--- a/src/server/Model/Message/Parts.hs
+++ b/src/server/Model/Message/Parts.hs
@@ -11,28 +11,27 @@ import qualified Data.Text as T
import Text.ParserCombinators.Parsec
-replaceParts :: [Text] -> [Part] -> Text
-replaceParts values = T.concat . map (replacePart values)
+import Model.Json.MessagePart
-replacePart :: [Text] -> Part -> Text
+replaceParts :: [Text] -> Text -> Text
+replaceParts values message =
+ T.concat . map (replacePart values) $ getParts message
+
+replacePart :: [Text] -> MessagePart -> Text
replacePart _ (Str str) = str
-replacePart values (Num n) =
+replacePart values (Order n) =
fromMaybe (T.concat ["{", T.pack (show n), "}"]) . listToMaybe . drop (n - 1) $ values
-data Part =
- Num Int
- | Str Text
-
-getParts :: Text -> [Part]
+getParts :: Text -> [MessagePart]
getParts str =
case parse partsParser "" (T.unpack str) of
Right parts -> parts
Left _ -> []
-partsParser :: Parser [Part]
+partsParser :: Parser [MessagePart]
partsParser = many partParser
-partParser :: Parser Part
+partParser :: Parser MessagePart
partParser =
- (do _ <- string "{"; n <- read <$> many1 digit; _ <- string "}"; return (Num n))
+ (do _ <- string "{"; n <- read <$> many1 digit; _ <- string "}"; return (Order n))
<|> (do str <- T.pack <$> many1 (noneOf "{"); return (Str str))
diff --git a/src/server/Model/Message/Translations.hs b/src/server/Model/Message/Translations.hs
index 289b714..2cc1761 100644
--- a/src/server/Model/Message/Translations.hs
+++ b/src/server/Model/Message/Translations.hs
@@ -14,6 +14,31 @@ getNonFormattedMessage = m
m :: Lang -> Key -> Text
+m l SharedCost =
+ case l of
+ English -> "Shared Cost"
+ French -> "Partage des frais"
+
+m l SignIn =
+ case l of
+ English -> "Sign in"
+ French -> "Connexion"
+
+m l SendEmailFail =
+ case l of
+ English -> "Sorry, we failed to send you the sign up email."
+ French -> "Désolé, nous n'avons pas pu vous envoyer le courriel de connexion."
+
+m l Unauthorized =
+ case l of
+ English -> "You are not authorized to sign in."
+ French -> "Vous n'êtes pas authorisé à vous connecter."
+
+m l EnterValidEmail =
+ case l of
+ English -> "Please enter a valid email address."
+ French -> "Entrez s'il vous plait un email valide."
+
m l January =
case l of
English -> "January"