glintl/locales

Pick a locale from a tag such as "en-GB", for example from an Accept-Language header or the browser’s language.

This module refers to every locale, which has a cost:

If you know which locales you need, import them from glintl/locale/ instead.

Generated by codegen/generate.ts. Do not edit.

Values

pub fn all() -> List(glintl.Locale)

Every locale glintl has. On Erlang this loads all their data.

pub fn from_tag(tag: String) -> Result(glintl.Locale, Nil)

Find a locale by its BCP 47 tag. Case and _ or - don’t matter.

If there is no exact match, the last part of the tag is dropped and it tries again, so "fr-CA-x-mine" gives Canadian French and "en-XX" gives English.

from_tag("en_GB")  // -> Ok(en_gb.locale())
from_tag("zh-TW")  // -> Ok(zh_hant.locale())
from_tag("xx")     // -> Error(Nil)
✨ Search Document