docspell/modules/webapp/src/main/elm/Data/Language.elm

50 lines
729 B
Elm
Raw Normal View History

2019-12-29 20:55:12 +00:00
module Data.Language exposing
( Language(..)
, all
, fromString
, toIso3
, toName
)
type Language
= German
| English
2019-12-29 20:55:12 +00:00
fromString : String -> Maybe Language
fromString str =
2019-12-29 20:55:12 +00:00
if str == "deu" || str == "de" || str == "german" then
Just German
else if str == "eng" || str == "en" || str == "english" then
Just English
else
Nothing
2019-12-29 20:55:12 +00:00
toIso3 : Language -> String
toIso3 lang =
case lang of
2019-12-29 20:55:12 +00:00
German ->
"deu"
2019-12-29 20:55:12 +00:00
English ->
"eng"
toName : Language -> String
toName lang =
case lang of
2019-12-29 20:55:12 +00:00
German ->
"German"
English ->
"English"
2019-12-29 20:55:12 +00:00
all : List Language
all =
[ German, English ]