rakutentech/r10/6.0.0

NOTE: the latest version is 7.0.0

R10.Language

Internationalization stuff

"Language" is sometime also called "Locale". We call it "Language" as it seems more common to refer to it this way.

Also in Html these are called "lang".

So we consider British English and American English as two different languages rather than two different locales of the same language.

= Key
| Lollipop
| EN_US
| JA_JP
| ZH_TW
| ZH_CN
| ES_ES
| FR_FR
| DE_DE
| IT_IT
| UK_UA
| PT_PT
| NL_NL
= International
| Localization
type alias Translations =
{ key : String
, en_us : String
, ja_jp : String
, zh_tw : String
, es_es : String
, fr_fr : String
, de_de : String
, zh_cn : String
, it_it : String
, uk_ua : String
, pt_pt : String
, nl_nl : String
}
decodeJsonString : List Language -> Value -> Result String Language
decoder : List Language -> String -> Result String Language
list : List Language
{ supportedLanguages : List Language
, navigatorLanguages : List String
}
-> Maybe Language
select : Language -> Translations -> String

Convert Language to full language description

Example to convert ZH_TW to translation in English and Traditional Chinese

toStringLong International ZH_TW ===> "Taiwanese"


toStringLong Localization ZH_TW ===> "繁體中文"
toString : Language -> String
urlParser : Parser (Language -> b) b

Parse Language from string (IETF format). It's case insensitive.

Parsing language from flags

Utils.I18n.Language.fromString "zh-TW" ===> Just ZH_TW


Utils.I18n.Language.fromString "ZH-TW" ===> Just ZH_TW


Utils.I18n.Language.fromString "foo" ===> Nothing