Ecma\Intl\Locale
- class Ecma\Intl\Locale
A Locale represents a Unicode locale identifier.
- property baseName string | null, readonly
The
baseNameproperty is a substring containing this locale’s core information, including language, script, region, and variant information.The
baseNamedoes not contain any of the locale’s keyword values.
- property calendar string | null, readonly
The
calendarproperty has the calendar type for this locale.If neither the
cakey of the locale identifier nor theEcma\Intl\Locale\Options::$calendaroption is set, this value is null.
- property calendars string[], readonly
- property caseFirst string | null, readonly
The
caseFirstproperty conveys whether case is taken into account for this locale’s collation rules.The
caseFirstproperty can have one of the following three values:"upper", meaning upper case values are sorted before lower case."lower", meaning lower case values are sorted before upper case."false", meaning there is no special case ordering (this is a string value and not a boolean).
If neither the
kfkey of the locale identifier nor theEcma\Intl\Locale\Options::$caseFirstoption is set, this value is null.
- property collation string | null, readonly
The
collationproperty has the collation type for this locale.The collation type is used to order strings according to the locale’s rules.
If neither the
cokey of the locale identifier nor theEcma\Intl\Locale\Options::$collationoption is set, this value is null.
- property collations string[], readonly
- property currencies string[], readonly
- property currency string | null, readonly
The
currencyproperty has the currency type for this locale.The currency type is the 3-character ISO 4217 currency code. If neither the
cukey of the locale identifier nor theEcma\Intl\Locale\Options::$currencyoption is set, this value is null.This property is not defined in ECMA-402 or in the Intl Locale Info Proposal. Instead, this is unique to the PHP implementation and is inspired by the Intl Locale Info Proposal.
- property hourCycle string | null, readonly
The
hourCycleproperty has the hour cycle type for this locale.The
hourCycleproperty can have one of the following four values:"h12", an hour system using 1-12 for a 12-hour clock, with midnight starting at 12:00 am."h23", an hour system using 0-23 for a 24-hour clock, with midnight starting at 0:00."h11", an hour system using 0-11 for a 12-hour clock, with midnight starting at 0:00 am."h24", an hour system using 1-24 for a 24-hour clock, with midnight starting at 24:00.
If neither the
hckey of the locale identifier nor theEcma\Intl\Locale\Options::$hourCycleoption is set, this value is null.
- property hourCycles string[], readonly
- property language string | null, readonly
The
languageproperty has the language code for this locale.In the case of an undefined language code (i.e., “und”), this value is
null.
- property numberingSystem string | null, readonly
The
numberingSystemproperty has the numeral system for this locale.If neither the
nukey of the locale identifier nor theEcma\Intl\Locale\Options::$numberingSystemoption is set, this value is null.
- property numberingSystems string[], readonly
- property numeric bool, readonly
The
numericproperty conveys whether this locale has special collation handling for numeric characters.
- property region string | null, readonly
The
regionproperty has the region code for this locale.If neither the region part of the locale identifier nor the
Ecma\Intl\Locale\Options::$regionoption is set, this value is null.
- property script string | null, readonly
The
scriptproperty has the script code for this locale.If neither the script part of the locale identifier nor the
Ecma\Intl\Locale\Options::$scriptoption is set, this value is null.
- property textInfo Ecma\Intl\Locale\TextInfo, readonly
- property timeZones string[] | null, readonly
- property weekInfo Ecma\Intl\Locale\WeekInfo, readonly
- __construct($tag[, $options = null])
Constructs an instance of a Unicode locale identifier.
- Parameters:
$tag (
Stringable | string) – The language tag (or locale identifier).$options (
Ecma\Intl\Locale\Options) – Additional options to apply to the locale. If the$tagalready has values for any of the options provided, the values on the$optionsparameter will override those on the$tag.
- __toString() string
Returns a string representation of the full locale identifier.
Alias of
Ecma\Intl\Locale::toString().
- getCalendars() string[]
Returns a list of one or more calendar types commonly used for this locale.
If the locale already includes a calendar (e.g.,
en-u-ca-buddhist) or one was provided via the constructor’s$optionsparameter, this list will contain only that calendar type.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
calendars, so most browsers implement this asLocale.calendars. However, recent drafts of this proposal have changed the design to the methodLocale.getCalendars(). As a result, this implementation provides bothEcma\Intl\Locale::getCalendars()andEcma\Intl\Locale::$calendars, each of which return the same value.
- getCollations() string[]
Returns a list of one or more collation types commonly used for this locale.
If the locale already includes a collation (e.g.,
en-u-co-emoji) or one was provided via the constructor’s$optionsparameter, this list will contain only that collation type.The
standardandsearchcollation types are always excluded from this list.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
collations, so most browsers implement this asLocale.collations. However, recent drafts of this proposal have changed the design to the methodLocale.getCollations(). As a result, this implementation provides bothEcma\Intl\Locale::getCollations()andEcma\Intl\Locale::$collations, each of which return the same value.
- getCurrencies() string[]
Returns a list of one or more currency types commonly used for this locale.
If the locale already includes a currency (e.g.,
en-u-cu-eur) or one was provided via the constructor’s$optionsparameter, this list will contain only that currency type.This method is not defined in ECMA-402 or in the Intl Locale Info Proposal in which other similar methods are described. Instead, this is unique to the PHP implementation and is inspired by the Intl Locale Info Proposal.
- getHourCycles() string[]
Returns a list of one or more hour cycle types commonly used for this locale.
If the locale already includes an hour cycle (e.g.,
en-u-hc-h11) or one was provided via the constructor’s$optionsparameter, this list will contain only that hour cycle type.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
hourCycles, so most browsers implement this asLocale.hourCycles. However, recent drafts of this proposal have changed the design to the methodLocale.getHourCycles(). As a result, this implementation provides bothEcma\Intl\Locale::getHourCycles()andEcma\Intl\Locale::$hourCycles, each of which return the same value.
- getNumberingSystems() string[]
Returns a list of one or more numbering systems commonly used for this locale.
If the locale already includes a numbering system (e.g.,
en-u-nu-arab) or one was provided via the constructor’s$optionsparameter, this list will contain only that numbering system.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
numberingSystems, so most browsers implement this asLocale.numberingSystems. However, recent drafts of this proposal have changed the design to the methodLocale.getNumberingSystems(). As a result, this implementation provides bothEcma\Intl\Locale::getNumberingSystems()andEcma\Intl\Locale::$numberingSystems, each of which return the same value.
- getTextInfo() Ecma\Intl\Locale\TextInfo
Returns an
Ecma\Intl\Locale\TextInfoobject representing typesetting information for the locale.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
textInfo, so most browsers implement this asLocale.textInfo. However, recent drafts of this proposal have changed the design to the methodLocale.getTextInfo(). As a result, this implementation provides bothEcma\Intl\Locale::getTextInfo()andEcma\Intl\Locale::$textInfo, each of which return the same value.
- getTimeZones() string[] | null
Returns a list of one or more time zone identifiers commonly used for this locale.
If the locale identifier does not contain a region subtag, this returns
null. If it has a region subtag but the region does not have any commonly used time zone identifiers, this returns an empty array.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
timeZones, so most browsers implement this asLocale.timeZones. However, recent drafts of this proposal have changed the design to the methodLocale.getTimeZones(). As a result, this implementation provides bothEcma\Intl\Locale::getTimeZones()andEcma\Intl\Locale::$timeZones, each of which return the same value.
- getWeekInfo() Ecma\Intl\Locale\WeekInfo
Returns an
Ecma\Intl\Locale\WeekInfoobject representing locale-specific information about the days of the week, for calendar purposes.This method is defined as part of the Intl Locale Info Proposal, an ECMA-402 stage 3 draft. Originally, it was defined as a property accessor named
weekInfo, so most browsers implement this asLocale.weekInfo. However, recent drafts of this proposal have changed the design to the methodLocale.getWeekInfo(). As a result, this implementation provides bothEcma\Intl\Locale::getWeekInfo()andEcma\Intl\Locale::$weekInfo, each of which return the same value.
- jsonSerialize() object
Returns an object of Locale properties and their values, suitable for serializing to JSON.
- maximize() Ecma\Intl\Locale
Returns a new instance of
Ecma\Intl\Localewith all likely sub tags added according to the algorithm in Unicode Technical Standard #35.For example:
“en” maximizes to “en-Latn-US”
“de” maximizes to “de-Latn-DE”
“sr” maximizes to “sr-Cyrl-RS”
“sh” maximizes to “sr-Latn-RS”
“zh” maximizes to “zh-Hans-CN”
- minimize() Ecma\Intl\Locale
Returns a new instance of
Ecma\Intl\Localewith sub tags removed according to the algorithm in Unicode Technical Standard #35.For example:
“en-Latn-US” minimizes to “en”
“de-Latn-DE” minimizes to “de”
“sr-Cyrl-RS” minimizes to “sr”
“zh-Hant-TW” minimizes to “zh-TW”
- toString() string
Returns a string representation of the full locale identifier.