public class Locale extends Object
A Locale object represents a specific geographical, political, or cultural region.
It is used to localize information such as date/time formatting, number formatting, and string translations. Language and country codes are normalized on construction and are read-only. Equality and hashing use only these codes, not customizable formatting data.
import klyn.i18n
locale = Locale("FR", "ca")
assert locale.language == "fr"
assert locale.country == "CA"
assert locale == Locale("fr", "CA")| Modifier and Type | Member | Description |
|---|---|---|
| public static readonly | ARABIC | Arabic (Saudi Arabia). |
| public static readonly | CHINA | Chinese (China). |
| public static readonly | FRANCE | French (France). |
| public static readonly | GERMANY | German (Germany). |
| public static readonly | GREECE | Greek (Greece). |
| public static readonly | HEBREW | Predefined constant for Hebrew (Israel). |
| public static readonly | ISRAEL | Hebrew (Israel). |
| public static readonly | ITALY | Italian (Italy). |
| public static readonly | JAPAN | Japanese (Japan). |
| public static readonly | PORTUGAL | Portuguese (Portugal). |
| public static readonly | RUSSIA | Russian (Russia). |
| public static readonly | SPAIN | Spanish (Spain). |
| public static readonly | UK | English (United Kingdom). |
| public static readonly | US | English (United States). |
| public static readonly | VIETNAM | Vietnamese (Vietnam). |
| Modifier and Type | Member | Description |
|---|---|---|
| public property | amPm | Morning and afternoon markers, in that order; mutable presentation data. |
| public readonly property | countrycountry as String |
Normalized country code. |
| public property | dayNames | Full day names, Sunday first. |
| public static property | defaultdefault as Locale |
Current default locale, initialized lazily from the environment. |
| public readonly property | languagelanguage as String |
Normalized language code. |
| public property | monthNames | Full month names, January first; mutable presentation data. |
| public property | shortDayNames | Abbreviated day names, Sunday first; mutable presentation data. |
| public property | shortMonthNames | Abbreviated month names, January first; mutable presentation data. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | Locale | Constructs a new Locale from language and country codes. |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | hashhash() as Long |
Hashes the same immutable codes used by equality. |
| public override | toStringtoString() as String |
Formats the normalized language and optional country, separated by _. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator!=(other as Locale) as Boolean | Tests whether normalized language or country codes differ. |
| public | operator==(other as Locale) as Boolean | Compares normalized language and country codes, not formatting data. |