Locale
classin packageklyn.i18n
public class Locale extends Object
└ Locale

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.

Example
import klyn.i18n
locale = Locale("FR", "ca")
assert locale.language == "fr"
assert locale.country == "CA"
assert locale == Locale("fr", "CA")
Fields
Modifier and Type Member Description
public static readonly ARABIC
ARABIC as Locale = Locale("ar", "SA")
Arabic (Saudi Arabia).
public static readonly CHINA
CHINA as Locale = Locale("zh", "CN")
Chinese (China).
public static readonly FRANCE
FRANCE as Locale = Locale("fr", "FR")
French (France).
public static readonly GERMANY
GERMANY as Locale = Locale("de", "DE")
German (Germany).
public static readonly GREECE
GREECE as Locale = Locale("el", "GR")
Greek (Greece).
public static readonly HEBREW
HEBREW as Locale = Locale("he", "IL")
Predefined constant for Hebrew (Israel).
public static readonly ISRAEL
ISRAEL as Locale = Locale("he", "IL")
Hebrew (Israel).
public static readonly ITALY
ITALY as Locale = Locale("it", "IT")
Italian (Italy).
public static readonly JAPAN
JAPAN as Locale = Locale("ja", "JP")
Japanese (Japan).
public static readonly PORTUGAL
PORTUGAL as Locale = Locale("pt", "PT")
Portuguese (Portugal).
public static readonly RUSSIA
RUSSIA as Locale = Locale("ru", "RU")
Russian (Russia).
public static readonly SPAIN
SPAIN as Locale = Locale("es", "ES")
Spanish (Spain).
public static readonly UK
UK as Locale = Locale("en", "GB")
English (United Kingdom).
public static readonly US
US as Locale = Locale("en", "US")
English (United States).
public static readonly VIETNAM
VIETNAM as Locale = Locale("vi", "VN")
Vietnamese (Vietnam).
Properties
Modifier and Type Member Description
public property amPm
amPm as ArrayList<String>
Morning and afternoon markers, in that order; mutable presentation data.
public readonly property country
country as String
Normalized country code.
public property dayNames
dayNames as ArrayList<String>
Full day names, Sunday first.
public static property default
default as Locale
Current default locale, initialized lazily from the environment.
public readonly property language
language as String
Normalized language code.
public property monthNames
monthNames as ArrayList<String>
Full month names, January first; mutable presentation data.
public property shortDayNames
shortDayNames as ArrayList<String>
Abbreviated day names, Sunday first; mutable presentation data.
public property shortMonthNames
shortMonthNames as ArrayList<String>
Abbreviated month names, January first; mutable presentation data.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public Locale
Locale(notnull language as String, notnull country as String = "")
Constructs a new Locale from language and country codes.
Methods
Modifier and Type Member Description
public override hash
hash() as Long
Hashes the same immutable codes used by equality.
public override toString
toString() as String
Formats the normalized language and optional country, separated by _.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
Operators
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.