Locale

Type
Class
Namespace
craft\i18n
Inherits
craft\i18n\Locale » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window)
Since
3.0.0

Stores locale info.

View source (opens new window)

# Public Properties

Property Description
aMName string (opens new window) – The "AM" name.
dateFormat string (opens new window) – The localized ICU date format.
dateTimeFormat string (opens new window) – The localized ICU date + time format.
displayName string (opens new window)
formatter craft\i18n\Formatter – A formatter for this locale.
id string (opens new window), null (opens new window) – The locale ID.
languageID string (opens new window) – This locale’s language ID.
monthNames array (opens new window) – The localized month names.
name string (opens new window), null (opens new window)
nativeName string (opens new window), false (opens new window)
orientation string (opens new window) – The language’s orientation.
pMName string (opens new window) – The "PM" name.
scriptID string (opens new window), null (opens new window) – The locale’s script ID, if it has one.
territoryID string (opens new window), null (opens new window) – The locale’s territory ID, if it has one.
timeFormat string (opens new window) – The localized ICU time format.
weekDayNames array (opens new window) – The localized day of the week names.

# aMName

Type
string (opens new window)
Default value
null
Access
Read-only

The "AM" name.

View source (opens new window)

# dateFormat

Type
string (opens new window)
Default value
null
Access
Read-only

The localized ICU date format.

View source (opens new window)

# dateTimeFormat

Type
string (opens new window)
Default value
null
Access
Read-only

The localized ICU date + time format.

View source (opens new window)

# displayName

Type
string (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# formatter

Type
craft\i18n\Formatter
Default value
null
Access
Read-only

A formatter for this locale.

View source (opens new window)

# id

Type
string (opens new window), null (opens new window)
Default value
null

The locale ID.

View source (opens new window)

# languageID

Type
string (opens new window)
Default value
null
Access
Read-only

This locale’s language ID.

View source (opens new window)

# monthNames

Type
array (opens new window)
Default value
null
Access
Read-only

The localized month names.

View source (opens new window)

# name

Type
string (opens new window), null (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# nativeName

Type
string (opens new window), false (opens new window)
Default value
null
Access
Read-only

View source (opens new window)

# orientation

Type
string (opens new window)
Default value
null
Access
Read-only

The language’s orientation.

View source (opens new window)

# pMName

Type
string (opens new window)
Default value
null
Access
Read-only

The "PM" name.

View source (opens new window)

# scriptID

Type
string (opens new window), null (opens new window)
Default value
null
Access
Read-only

The locale’s script ID, if it has one.

View source (opens new window)

# territoryID

Type
string (opens new window), null (opens new window)
Default value
null
Access
Read-only

The locale’s territory ID, if it has one.

View source (opens new window)

# timeFormat

Type
string (opens new window)
Default value
null
Access
Read-only

The localized ICU time format.

View source (opens new window)

# weekDayNames

Type
array (opens new window)
Default value
null
Access
Read-only

The localized day of the week names.

View source (opens new window)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() Constructor.
__get() (opens new window) Returns the value of an object property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets value of an object property.
__toString() Use the ID as the string representation of locales.
__unset() (opens new window) Sets an object property to null.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
className() (opens new window) Returns the fully qualified name of this class.
getAMName() Returns the "AM" name for this locale.
getCurrencySymbol() Returns this locale’s symbol for a given currency.
getDateFormat() Returns the localized ICU date format.
getDateTimeFormat() Returns the localized ICU date + time format.
getDisplayName() Returns the locale name in a given language.
getFormatter() Returns a craft\i18n\Formatter for this locale.
getId() Returns the locale ID.
getLanguageID() Returns this locale’s language ID.
getMonthName() Returns a localized month name.
getMonthNames() Returns all of the localized month names.
getName() Returns the locale name in a given language.
getNativeName() Returns the locale name in its own language.
getNumberPattern() Returns a number pattern used by this locale.
getNumberSymbol() Returns a number symbol used by this locale.
getOrientation() Returns the language’s orientation (ltr or rtl).
getPMName() Returns the "PM" name for this locale.
getScriptID() Returns this locale’s script ID.
getTerritoryID() Returns this locale’s territory ID.
getTextAttribute() Returns a text attribute used by this locale.
getTimeFormat() Returns the localized ICU time format.
getWeekDayName() Returns a localized day of the week name.
getWeekDayNames() Returns all of the localized day of the week names.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined.
init() (opens new window) Initializes the object.

# __construct()

Constructor.

View source (opens new window)

Arguments

Throws

# __toString()

Use the ID as the string representation of locales.

View source (opens new window)

Returns

string (opens new window)

# getAMName()

Returns the "AM" name for this locale.

View source (opens new window)

Returns

string (opens new window) – The "AM" name.

# getCurrencySymbol()

Returns this locale’s symbol for a given currency.

View source (opens new window)

Arguments

Returns

string (opens new window) – The currency symbol.

# getDateFormat()

Returns the localized ICU date format.

View source (opens new window)

Arguments

Returns

string (opens new window) – The localized ICU date format.

# getDateTimeFormat()

Returns the localized ICU date + time format.

View source (opens new window)

Arguments

Returns

string (opens new window) – The localized ICU date + time format.

# getDisplayName()

Returns the locale name in a given language.

View source (opens new window)

Arguments

Returns

string (opens new window)

# getFormatter()

Returns a craft\i18n\Formatter for this locale.

View source (opens new window)

Returns

craft\i18n\Formatter – A formatter for this locale.

# getId()

DEPRECATED

Deprecated in 3.0.0. Use id instead.

Returns the locale ID.

View source (opens new window)

Returns

string (opens new window)

# getLanguageID()

Returns this locale’s language ID.

View source (opens new window)

Returns

string (opens new window) – This locale’s language ID.

# getMonthName()

Returns a localized month name.

View source (opens new window)

Arguments

Returns

string (opens new window) – The localized month name.

# getMonthNames()

Returns all of the localized month names.

View source (opens new window)

Arguments

Returns

array (opens new window) – The localized month names.

# getName()

DEPRECATED

Deprecated in 3.0.0. Use getDisplayName() instead.

Returns the locale name in a given language.

View source (opens new window)

Arguments

Returns

string (opens new window), null (opens new window)

# getNativeName()

DEPRECATED

Deprecated in 3.0.0. Use getDisplayName() instead.

Returns the locale name in its own language.

View source (opens new window)

Returns

string (opens new window), false (opens new window)

# getNumberPattern()

Returns a number pattern used by this locale.

View source (opens new window)

Arguments

  • $style (integer (opens new window)) – The pattern style to return. Accepted values: Locale::STYLE_DECIMAL, ::STYLE_CURRENCY, ::STYLE_PERCENT, ::STYLE_SCIENTIFIC

Returns

string (opens new window), null (opens new window) – The pattern

# getNumberSymbol()

Returns a number symbol used by this locale.

View source (opens new window)

Arguments

  • $symbol (integer (opens new window)) – The symbol to return. Accepted values: Locale::SYMBOL_DECIMAL_SEPARATOR, ::SYMBOL_GROUPING_SEPARATOR, ::SYMBOL_PATTERN_SEPARATOR, ::SYMBOL_PERCENT, ::SYMBOL_ZERO_DIGIT, ::SYMBOL_DIGIT, ::SYMBOL_MINUS_SIGN, ::SYMBOL_PLUS_SIGN, ::SYMBOL_CURRENCY, ::SYMBOL_INTL_CURRENCY, ::SYMBOL_MONETARY_SEPARATOR, ::SYMBOL_EXPONENTIAL, ::SYMBOL_PERMILL, ::SYMBOL_PAD_ESCAPE, ::SYMBOL_INFINITY, ::SYMBOL_NAN, ::SYMBOL_SIGNIFICANT_DIGIT, ::SYMBOL_MONETARY_GROUPING_SEPARATOR

Returns

string (opens new window), null (opens new window) – The symbol.

# getOrientation()

Returns the language’s orientation (ltr or rtl).

View source (opens new window)

Returns

string (opens new window) – The language’s orientation.

# getPMName()

Returns the "PM" name for this locale.

View source (opens new window)

Returns

string (opens new window) – The "PM" name.

# getScriptID()

Returns this locale’s script ID.

A script ID consists of only the last four characters after a dash in the locale ID.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The locale’s script ID, if it has one.

# getTerritoryID()

Returns this locale’s territory ID.

A territory ID consists of only the last two to three letter or digits after a dash in the locale ID.

View source (opens new window)

Returns

string (opens new window), null (opens new window) – The locale’s territory ID, if it has one.

# getTextAttribute()

Returns a text attribute used by this locale.

View source (opens new window)

Arguments

Returns

string (opens new window), null (opens new window) – The attribute.

# getTimeFormat()

Returns the localized ICU time format.

View source (opens new window)

Arguments

Returns

string (opens new window) – The localized ICU time format.

# getWeekDayName()

Returns a localized day of the week name.

View source (opens new window)

Arguments

Returns

string (opens new window) – The localized day of the week name.

# getWeekDayNames()

Returns all of the localized day of the week names.

View source (opens new window)

Arguments

Returns

array (opens new window) – The localized day of the week names.

# Constants

Constant Description
ATTR_CURRENCY_CODE
ATTR_DEFAULT_RULESET
ATTR_NEGATIVE_PREFIX
ATTR_NEGATIVE_SUFFIX
ATTR_PADDING_CHARACTER
ATTR_POSITIVE_PREFIX
ATTR_POSITIVE_SUFFIX
ATTR_PUBLIC_RULESETS
FORMAT_ICU
FORMAT_JUI
FORMAT_PHP
LENGTH_ABBREVIATED
LENGTH_FULL
LENGTH_LONG
LENGTH_MEDIUM
LENGTH_SHORT
STYLE_CURRENCY
STYLE_DECIMAL
STYLE_PERCENT
STYLE_SCIENTIFIC
SYMBOL_CURRENCY
SYMBOL_DECIMAL_SEPARATOR
SYMBOL_DIGIT
SYMBOL_EXPONENTIAL
SYMBOL_GROUPING_SEPARATOR
SYMBOL_INFINITY
SYMBOL_INTL_CURRENCY
SYMBOL_MINUS_SIGN
SYMBOL_MONETARY_GROUPING_SEPARATOR
SYMBOL_MONETARY_SEPARATOR
SYMBOL_NAN
SYMBOL_PAD_ESCAPE
SYMBOL_PATTERN_SEPARATOR
SYMBOL_PERCENT
SYMBOL_PERMILL
SYMBOL_PLUS_SIGN
SYMBOL_SIGNIFICANT_DIGIT
SYMBOL_ZERO_DIGIT