
locals events keys =
  -- For each event, get all the localisation keys and pair them with the name of the file
  let usedKeys = S.fromList $ concatMap (\e → map (`emptyEntry` (fileFromSource $ Event.source e)) $ GL.localisations e) $ S.toList events in
  let notDefined = usedKeys `S.difference` keys in
  "Used keys: " <> T.pack (show $ S.size usedKeys)
  <> ("\nUndefined keys:\n" <> T.unlines (S.toList
                          $ S.map (\l → Localisation.key l
                                      <> " in "
                                      <> T.pack (Localisation.source l))
                          notDefined))
  <> "Total undefined keys: " <> T.pack (show $ S.size notDefined)
  where emptyEntry k = Entry k "" "" "" "" "" "" "" ""

        fileFromSource (Just s) = sourceName s
        fileFromSource Nothing = "unknown"

traits (_,modEvents) (_,modDecisions) = T.unlines 
locals :: S.Set Event → S.Set Entry → T.Text
locals events keys =
  -- For each event, get all the localisation keys and pair them with the name of the file
  let usedKeys = S.fromList $ concatMap (\e → map (`emptyEntry` (fileFromSource $ Event.source e)) $ GL.localisations e) $ S.toList events in
  let notDefined = usedKeys `S.difference` keys in
  "Used keys: " <> T.pack (show $ S.size usedKeys)
  <> ("\nUndefined keys:\n" <> T.unlines (S.toList
                          $ S.map (\l → Localisation.key l
                                      <> " in "
                                      <> T.pack (Localisation.source l))
                          notDefined))
  <> "Total undefined keys: " <> T.pack (show $ S.size notDefined)
  where emptyEntry k = Entry k "" "" "" "" "" "" "" ""

        fileFromSource (Just s) = sourceName s
        fileFromSource Nothing = "unknown"
locals events keys =
  -- For each event, get all the localisation keys and pair them with the name of the file
  let usedKeys = S.fromList $ concatMap (\e → map (`emptyEntry` (fileFromSource $ Event.source e)) $ GL.localisations e) $ S.toList events in
  let notDefined = usedKeys `S.difference` keys in
  "Used keys: " <> T.pack (show $ S.size usedKeys)
  <> ("\nUndefined keys:\n" <> T.unlines (S.toList
                          $ S.map (\l → Localisation.key l
                                      <> " in "
                                      <> T.pack (Localisation.source l))
                          notDefined))
  <> "Total undefined keys: " <> T.pack (show $ S.size notDefined)
  where emptyEntry k = Entry k "" "" "" "" "" "" "" ""

        fileFromSource (Just s) = sourceName s
        fileFromSource Nothing = "unknown"