module BtcLsp.Yesod.TH
  ( mkMessageNoFallback,
  )
where

import BtcLsp.Yesod.Import.NoFoundation hiding (forM_)
import Data.Foldable (forM_)
import Data.List.NonEmpty
import Language.Haskell.TH.Syntax

mkMessageNoFallback ::
  -- | base name to use for translation type
  String ->
  -- | subdirectory which contains the translation files
  FilePath ->
  -- | default translation language is first
  NonEmpty Lang ->
  Q [Dec]
mkMessageNoFallback :: String -> String -> NonEmpty Lang -> Q [Dec]
mkMessageNoFallback String
dt String
folder (Lang
lang :| [Lang]
langs) = do
  [Lang] -> (Lang -> Q [Dec]) -> Q ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [Lang]
langs ((Lang -> Q [Dec]) -> Q ()) -> (Lang -> Q [Dec]) -> Q ()
forall a b. (a -> b) -> a -> b
$ String -> String -> Lang -> Q [Dec]
mkMessage String
dt String
folder
  String -> String -> Lang -> Q [Dec]
mkMessage String
dt String
folder Lang
lang