Lang :: I18N  -- ^ The 'I18N' database to fetch translations from.
       -> Lang  -- ^ The 'Lang'uage to fetch translation for.
       -> Text  -- ^ The 'Text' to translate.
       -> Text  -- ^ The translation of the input 'Text'.
toLang db lang key = maybe (trace ("!!! Warning: no i18n db for key `" ++ T.unpack key ++ "'") key)
                           (fromMaybe fallback . Map.lookup lang) (Map.lookup key db)
  where
    fallback | "fi" <- lang = key
             | otherwise    = trace ("!!! Warning: no i18n for key `" ++ T.unpack key ++ "' with lang `" ++ T.unpack lang ++ "'") key


{- | Access the 'ColumnHeader' information with name of the column and with a
    key to the information desired.

    Returns the value of the desired column information. If the column name
    doesn't exist it'll show a warning in the output and an empty 'Text' is
    returned instead.
-}
c
toLang :: I18N  -- ^ The 'I18N' database to fetch translations from.
       -> Lang  -- ^ The 'Lang'uage to fetch translation for.
       -> Text  -- ^ The 'Text' to translate.
       -> Text
toLang db lang key = maybe (trace ("!!! Warning: no i18n db for key `" ++ T.unpack key ++ "'") key)
                           (fromMaybe fallback . Map.lookup lang) (Map.lookup key db)
  where
    fallback | "fi" <- lang = key
             | otherwise    = trace ("!!! Warning: no i18n for key `" ++ T.unpack key ++ "' with lang `" ++ T.unpack lang ++ "'") key


{- | Access the 'ColumnHeader' information with name of the column and with a
    key to the information desired.

    Returns the value of the desired column information. If the column name
    doesn't exist it'll show a warning in the output and an empty 'Text' is
    returned instead.
-}
toLang db lang key = maybe (trace ("!!! Warning: no i18n db for key `" ++ T.unpack key ++ "'") key)
                           (fromMaybe fallback . Map.lookup lang) (Map.lookup key db)
  where
    fallback | "fi" <- lang = key
             | otherwise    = trace ("!!! Warning: no i18n for key `" ++ T.unpack key ++ "' with lang `" ++ T.unpack lang ++ "'") key


{- | Access the 'ColumnHeader' information with name of the column and with a
    key to the information desired.

    Returns the value of the desired column information. If the column name
    doesn't exist it'll show a warning in the output and an empty 'Text' is
    returned instead.
-}