Locale

Type
Class
Namespace
craft\i18n
Inherits
craft\i18n\Locale » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0

Stores locale info.

View source

Public Properties

PropertyDescription
$aMNamestring – The "AM" name.
$dateFormatstring – The localized ICU date format.
$dateTimeFormatstring – The localized ICU date + time format.
$displayNamestring
$formattercraft\i18n\Formatter – A formatter for this locale.
$idstring, null – The locale ID.
$languageIDstring – This locale’s language ID.
$monthNamesarray – The localized month names.
$namestring, null
$nativeNamestring, false
$orientationstring – The language’s orientation.
$pMNamestring – The "PM" name.
$scriptIDstring, null – The locale’s script ID, if it has one.
$territoryIDstring, null – The locale’s territory ID, if it has one.
$timeFormatstring – The localized ICU time format.
$weekDayNamesarray – The localized day of the week names.

$aMName

Type
string
Access
Read-only

The "AM" name.

View source

Signature

public string getAMName ( )

$dateFormat

Type
string
Access
Read-only

The localized ICU date format.

View source

Signature

public string getDateFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

$dateTimeFormat

Type
string
Access
Read-only

The localized ICU date + time format.

View source

Signature

public string getDateTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

$displayName

Type
string
Access
Read-only

View source

Signature

public string getDisplayName ( \craft\i18n\string $inLocale = null )

$formatter

Type
craft\i18n\Formatter
Access
Read-only

A formatter for this locale.

View source

Signature

public craft\i18n\Formatter getFormatter ( )

$id

Type
string, null
Access
Read-only

The locale ID.

View source

Signature

public string getId ( )

$languageID

Type
string
Access
Read-only

This locale’s language ID.

View source

Signature

public string getLanguageID ( )

$monthNames

Type
array
Access
Read-only

The localized month names.

View source

Signature

public array getMonthNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

$name

Type
string, null
Access
Read-only

View source

Signature

public string, null getName ( \craft\i18n\string $targetLocaleId = null )

$nativeName

Type
string, false
Access
Read-only

View source

Signature

public string, false getNativeName ( )

$orientation

Type
string
Access
Read-only

The language’s orientation.

View source

Signature

public string getOrientation ( )

$pMName

Type
string
Access
Read-only

The "PM" name.

View source

Signature

public string getPMName ( )

$scriptID

Type
string, null
Access
Read-only

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

View source

Signature

public string, null getScriptID ( )

$territoryID

Type
string, null
Access
Read-only

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

View source

Signature

public string, null getTerritoryID ( )

$timeFormat

Type
string
Access
Read-only

The localized ICU time format.

View source

Signature

public string getTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

$weekDayNames

Type
array
Access
Read-only

The localized day of the week names.

View source

Signature

public array getWeekDayNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__toString()Use the ID as the string representation of locales.
__unset()Sets an object property to null.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()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()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.

__construct()

Constructor.

View source

Arguments

  • $id (string) – The locale ID.
  • $config (array) – Name-value pairs that will be used to initialize the object properties.

Throws

Signature

public void __construct ( \craft\i18n\string $id, array $config = [] )

__toString()

Use the ID as the string representation of locales.

View source

Returns

string

Signature

public string __toString ( )

getAMName()

Returns the "AM" name for this locale.

View source

Returns

string – The "AM" name.

Signature

public string getAMName ( )

getCurrencySymbol()

Returns this locale’s symbol for a given currency.

View source

Arguments

  • $currency (string) – The 3-letter ISO 4217 currency code indicating the currency to use.

Returns

string – The currency symbol.

Signature

public string getCurrencySymbol ( \craft\i18n\string $currency )

getDateFormat()

Returns the localized ICU date format.

View source

Arguments

  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_SHORT, ::MEDIUM, ::LONG, ::FULL
  • $format (string) – The format type that should be returned. Values: Locale::FORMAT_ICU (default), ::FORMAT_PHP, ::FORMAT_JUI

Returns

string – The localized ICU date format.

Signature

public string getDateFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

getDateTimeFormat()

Returns the localized ICU date + time format.

View source

Arguments

  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_SHORT, ::MEDIUM, ::LONG, ::FULL
  • $format (string) – The format type that should be returned. Values: Locale::FORMAT_ICU (default), ::FORMAT_PHP, ::FORMAT_JUI

Returns

string – The localized ICU date + time format.

Signature

public string getDateTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

getDisplayName()

Returns the locale name in a given language.

View source

Arguments

Returns

string

Signature

public string getDisplayName ( \craft\i18n\string $inLocale = null )

getFormatter()

Returns a craft\i18n\Formatter for this locale.

View source

Returns

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

Signature

public craft\i18n\Formatter getFormatter ( )

getId()

DEPRECATED

Deprecated in 3.0. Use id instead.

Returns the locale ID.

View source

Returns

string

Signature

public string getId ( )

getLanguageID()

Returns this locale’s language ID.

View source

Returns

string – This locale’s language ID.

Signature

public string getLanguageID ( )

getMonthName()

Returns a localized month name.

View source

Arguments

  • $month (integer) – The month to return (1-12).
  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_ABBREVIATED, ::MEDIUM, ::FULL
  • $standAlone (boolean) – Whether to return the "stand alone" month name.

Returns

string – The localized month name.

Signature

public string getMonthName ( \craft\i18n\int $month, \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

getMonthNames()

Returns all of the localized month names.

View source

Arguments

  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_ABBREVIATED, ::MEDIUM, ::FULL
  • $standAlone (boolean) – Whether to return the "stand alone" month names.

Returns

array – The localized month names.

Signature

public array getMonthNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

getName()

DEPRECATED

Deprecated in 3.0. Use getDisplayName() instead.

Returns the locale name in a given language.

View source

Arguments

Returns

string, null

Signature

public string, null getName ( \craft\i18n\string $targetLocaleId = null )

getNativeName()

DEPRECATED

Deprecated in 3.0. Use getDisplayName() instead.

Returns the locale name in its own language.

View source

Returns

string, false

Signature

public string, false getNativeName ( )

getNumberPattern()

Returns a number pattern used by this locale.

View source

Arguments

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

Returns

string, null – The pattern

Signature

public string, null getNumberPattern ( \craft\i18n\int $style )

getNumberSymbol()

Returns a number symbol used by this locale.

View source

Arguments

  • $symbol (integer) – 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, null – The symbol.

Signature

public string, null getNumberSymbol ( \craft\i18n\int $symbol )

getOrientation()

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

View source

Returns

string – The language’s orientation.

Signature

public string getOrientation ( )

getPMName()

Returns the "PM" name for this locale.

View source

Returns

string – The "PM" name.

Signature

public string getPMName ( )

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

Returns

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

Signature

public string, null getScriptID ( )

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

Returns

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

Signature

public string, null getTerritoryID ( )

getTextAttribute()

Returns a text attribute used by this locale.

View source

Arguments

  • $attribute (integer) – The attribute to return. Values: Locale::

Returns

string, null – The attribute.

Signature

public string, null getTextAttribute ( \craft\i18n\int $attribute )

getTimeFormat()

Returns the localized ICU time format.

View source

Arguments

  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_SHORT, ::MEDIUM, ::LONG, ::FULL
  • $format (string) – The format type that should be returned. Values: Locale::FORMAT_ICU (default), ::FORMAT_PHP, ::FORMAT_JUI

Returns

string – The localized ICU time format.

Signature

public string getTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )

getWeekDayName()

Returns a localized day of the week name.

View source

Arguments

  • $day (integer) – The day of the week to return (0-6), where 0 stands for Sunday.
  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_ABBREVIATED, ::SHORT, ::MEDIUM, ::FULL
  • $standAlone (boolean) – Whether to return the "stand alone" day of the week name.

Returns

string – The localized day of the week name.

Signature

public string getWeekDayName ( \craft\i18n\int $day, \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

getWeekDayNames()

Returns all of the localized day of the week names.

View source

Arguments

  • $length (string, null) – The format length that should be returned. Values: Locale::LENGTH_ABBREVIATED, ::MEDIUM, ::FULL
  • $standAlone (boolean) – Whether to return the "stand alone" day of the week names.

Returns

array – The localized day of the week names.

Signature

public array getWeekDayNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )

Constants

ConstantDescription
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