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:
- On JavaScript, bundlers can’t leave out the locales you don’t use, so
your bundle grows by about 13 KB gzipped. It’s not more because each
locale is just its tag: the formats come from the runtime’s
Intl. - On Erlang,
from_tagloads this module, about 0.4 MB, and the data for the one locale it finds.allloads every locale’s data, about 2.3 MB more.
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)