LanguageValues and typesStandard typesPlaces
Locale
On this page
A language and region together, which decides how dates and numbers look: en-GB.
Use it whenever you format something for a person, and to store which they prefer. To say only which language a document is in, use Language.
Shape
One of 534 values, such as Locale.af, written af. Details has them.
Example
Locale.en_gbtext.parse(raw, as: Locale) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as english or xx-YY.
This operation gives one: locale.from_accept_language.
Good to know
- Each value is its tag in lower case with
_for-:Locale.en_gbisen-GB. locale.from_accept_languagepicks one from a browser's request header.==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
A string, in a request, a response or json.write:
"en-GB""fr-FR"
Details
Text form, storage, how it is shown, and operations
Locale is in the group Places, and has been in Jadpo since 0.1.0.
Every value
The first 40 of 534; jadpo help Locale --json lists every one:
af, af_na (af-NA), af_za (af-ZA), ak, ak_gh (ak-GH), am, am_et (am-ET), ar, ar_ae (ar-AE), ar_bh (ar-BH), ar_dj (ar-DJ), ar_dz (ar-DZ), ar_eg (ar-EG), ar_eh (ar-EH), ar_er (ar-ER), ar_il (ar-IL), ar_iq (ar-IQ), ar_jo (ar-JO), ar_km (ar-KM), ar_kw (ar-KW), ar_lb (ar-LB), ar_ly (ar-LY), ar_ma (ar-MA), ar_mr (ar-MR), ar_om (ar-OM), ar_ps (ar-PS), ar_qa (ar-QA), ar_sa (ar-SA), ar_sd (ar-SD), ar_so (ar-SO), ar_ss (ar-SS), ar_sy (ar-SY), ar_td (ar-TD), ar_tn (ar-TN), ar_ye (ar-YE), as, as_in (as-IN), az, az_az (az-AZ), az_latn (az-Latn).
Text form
text.from writes one standard text form, the same form text.parse reads back: en-GB and fr-FR.
How it is stored
It is stored in one column named for the field, of type text. fr-FR is stored as 'fr-FR'.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
en-GB |
British English |
fr-FR |
French (France) |
Operations
list.sort_by(items: List<T>, key: Function<T, K>, locale: Locale?) -> List<T>: A new list ordered bykey, smallest first; items with equal keys keep their order. Text keys go by code point, or bylocale's rules when it is given.locale.direction(value: Locale) -> TextDirection: Which wayvalue's text runs, as CLDR says:TextDirection.left_to_rightfor English,TextDirection.right_to_leftfor Arabic and Hebrew.locale.from_accept_language(header: Text?) -> Locale: The supportedLocaleanAccept-Languageheader asks for, orlocales { default: }when it names none the application supports, is malformed or isnone.temporal.format_relative(value: T, now: Instant, zone: Zone?, locale: Locale) -> PresentationText:valueshown to a person inlocaleas how long ago it was fromnow: "just now", minutes, "Today at", "Yesterday at", the weekday, then the long date.text.lower(value: Text, locale: Locale?) -> Text:valuein lower case, bylocale's rules when it is given.text.pick(value: LocalisedText, locale: Locale) -> Text: The text invalueforlocale: its entry, else the entry of its language (the locale CLDR's likely subtags give for the language first), else the application's default locale's, else the first.text.upper(value: Text, locale: Locale?) -> Text:valuein upper case, bylocale's rules when it is given.
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-locale.md.Built from Jadpo main at aee2e8f.