blob: 026967f4dee848fa342c736b63e5d5b1f8f0d077 (
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
31
32
33
34
35
|
module Model.Message
( getMessage
, getParamMessage
, getTranslations
, plural
) 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)
plural :: Int -> Key -> Key -> Text
plural count singularKey pluralKey =
getParamMessage [T.pack . show $ count] (if count <= 1 then singularKey else pluralKey)
|