diff options
Diffstat (limited to 'src/server/Model/Message.hs')
-rw-r--r-- | src/server/Model/Message.hs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/server/Model/Message.hs b/src/server/Model/Message.hs index d84aaa9..8475740 100644 --- a/src/server/Model/Message.hs +++ b/src/server/Model/Message.hs @@ -1,16 +1,29 @@ -{-# LANGUAGE DeriveGeneric #-} - module Model.Message - ( Message(..) + ( getMessage + , getVarMessage + , getTranslations ) where -import Data.Aeson import Data.Text (Text) -import GHC.Generics +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.Translations +import Model.Json.Translation + +getMessage :: Key -> Text +getMessage = getVarMessage [] + +getVarMessage :: [Text] -> Key -> Text +getVarMessage values key = + replaceParts values (getParts (getNonFormattedMessage lang key)) -data Message = Message - { message :: Text - } deriving (Show, Generic) +getTranslations :: Translations +getTranslations = Translations (map getTranslation [minBound..]) -instance FromJSON Message -instance ToJSON Message +getTranslation :: Key -> Translation +getTranslation key = Translation (T.pack . show $ key) (getNonFormattedMessage lang key) |