1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{-|
Module : Gargantext.Core
Description : Supported Natural language
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module Gargantext.Core
where
import Gargantext.Prelude
import GHC.Generics (Generic)
import Data.Aeson
import Data.Either(Either(Left))
import Data.Swagger
import Servant.API
------------------------------------------------------------------------
-- | Language of a Text
-- For simplicity, we suppose text has an homogenous language
--
-- Next steps: | DE | IT | SP
--
-- - EN == english
-- - FR == french
-- - DE == deutch (not implemented yet)
-- - IT == italian (not implemented yet)
-- - SP == spanish (not implemented yet)
--
-- ... add your language and help us to implement it (:
-- | All languages supported
-- TODO : DE | SP | CH
data Lang = EN | FR | All
deriving (Show, Eq, Ord, Bounded, Enum, Generic)
instance ToJSON Lang
instance FromJSON Lang
instance ToSchema Lang
instance FromHttpApiData Lang
where
parseUrlPiece "EN" = pure EN
parseUrlPiece "FR" = pure FR
parseUrlPiece "All" = pure All
parseUrlPiece _ = Left "Unexpected value of OrderBy"
allLangs :: [Lang]
allLangs = [minBound ..]