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.Translations
import Model.Json.Translation

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

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

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

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