Lang.purs 1022 Bytes
Newer Older
1
module Gargantext.Components.Lang where
2

3 4
import Data.Argonaut (class EncodeJson, encodeJson)
import Data.Maybe (Maybe(..))
5
import Gargantext.Prelude (class Eq, class Show, show, class Read)
6 7 8 9 10 11 12 13 14 15 16

-- Language used for search
allLangs :: Array Lang
allLangs = [ EN
           , FR
           , Universal
           , No_extraction
           ]

data Lang = FR | EN | Universal | No_extraction

17
instance Show Lang where
18 19 20
  show FR            = "FR"
  show EN            = "EN"
  show Universal     = "All"
21 22
  show No_extraction = "Nothing"

23
derive instance Eq Lang
24

25
instance Read Lang where
26 27 28 29 30
  read "FR"      = Just FR
  read "EN"      = Just EN
  read "All"     = Just Universal
  read "Nothing" = Just No_extraction
  read _         = Nothing
31

32

33
instance EncodeJson Lang where
34 35 36 37
  encodeJson a = encodeJson (show a)

-- Language used for the landing page
data LandingLang = LL_EN | LL_FR
38 39 40 41

-- @TODO a possible method/class that a real i18n logic could later replace
class Show t <= Translate t where
  translate :: Lang -> t -> String