type

Locale

src @Serializable { simple=true }
const class Locale : Obj

Locale models a cultural language and region/country. See Localization for details.

Also see Env.locale and Pod.locale.

constructors

fromStr

Parse a locale according to the toStr format.

fields

en

Constant for the English Locale "en"

methods

country

Get the country/region as an uppercase ISO 3166 two letter code.

cur

Get the current thread's locale.

equals

Equality is based on the normalized toStr format.

hash

Compute hash code based on normalized toStr format.

lang

Get the language as a lowercase ISO 639 two letter code.

setCur

Set the current thread's locale.

toStr

Return string representation

use

Run the specified function using this locale as the actor's current locale.

Slot Details

country

src Str? country()

Get the country/region as an uppercase ISO 3166 two letter code. Return null if the country is unspecified.

cur

src static Locale cur()

Get the current thread's locale.

en

src const static Locale en

Constant for the English Locale "en"

equals

src virtual override Bool equals(Obj? obj)

Equality is based on the normalized toStr format.

fromStr

src static new fromStr(Str s, Bool checked := true)

Parse a locale according to the toStr format. If invalid format and checked is false return null, otherwise throw ParseErr.

hash

src virtual override Int hash()

Compute hash code based on normalized toStr format.

lang

src Str lang()

Get the language as a lowercase ISO 639 two letter code.

setCur

src static Void setCur(Locale locale)

Set the current thread's locale. Throw NullErr if null is passed.

toStr

src virtual override Str toStr()

Return string representation:

<locale>  := <lang> ["-" <country>]
<lang>    := lowercase ISO 636 two letter code
<country> := uppercase ISO 3166 two letter code

use

src This use(|This| func)

Run the specified function using this locale as the actor's current locale. This method guarantees that upon return the actor's current locale remains unchanged.