/bcp47

parse language tags according to bcp 47 in elm

Primary LanguageElmApache License 2.0Apache-2.0

BCP 47 Build Status

This library lets you parse language tags according to the specifications in BCP 47: strings like "zh-cmn-Hans-CN", "en-US", "ja-JP-u-ca-japanese", "x-whatever", ... . The first one, for example, would be turned into

languageTag =
    LanguageTag
        { language =
            { shortestIso639Code = "zh"
            , extension =
                Just
                    { selectedIso639Code = "cmn"
                    , reserved = []
                    }
            }
        , script = Just "Hans"
        , region = Just (ISO3166_1 "CN")
        , variants = []
        , extensions = []
        , privateUse = []
        }

You can also turn these data back into canonicalized strings.