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)