aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Message.hs
blob: 0e83e5b054e9bcb496e95491195458a95e2629dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Model.Message
  ( getMessage
  , getParamMessage
  , getTranslations
  ) where

import Data.Text (Text)
import qualified Data.Text as T

import Model.Message.Key (Key)
import Model.Message.Lang
import Model.Message.Translations (getNonFormattedMessage)
import Model.Message.Parts

import Model.Json.Translation

getMessage :: Key -> Text
getMessage = getParamMessage []

getParamMessage :: [Text] -> Key -> Text
getParamMessage values paramKey = replaceParts values (getNonFormattedMessage lang paramKey)

getTranslations :: [Translation]
getTranslations = (map getTranslation [minBound..])

getTranslation :: Key -> Translation
getTranslation translationKey =
  Translation
    (T.pack . show $ translationKey)
    (getParts $ getNonFormattedMessage lang translationKey)