Class craft\i18n\Locale
- Inheritance
- craft\i18n\Locale » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/i18n/Locale.php
Stores locale info.
Property | Type | Description | Defined By |
---|---|---|---|
$id |
string, null | The locale ID. | craft\i18n\Locale |
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() |
Constructor. | craft\i18n\Locale |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__toString() |
Use the ID as the string representation of locales. | craft\i18n\Locale |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
getAMName() |
Returns the "AM" name for this locale. | craft\i18n\Locale |
getCurrencySymbol() |
Returns this locale’s symbol for a given currency. | craft\i18n\Locale |
getDateFormat() |
Returns the localized ICU date format. | craft\i18n\Locale |
getDateTimeFormat() |
Returns the localized ICU date + time format. | craft\i18n\Locale |
getDisplayName() |
Returns the locale name in a given language. | craft\i18n\Locale |
getFormatter() |
Returns a craft\i18n\Formatter for this locale. | craft\i18n\Locale |
getId() |
Returns the locale ID. | craft\i18n\Locale |
getLanguageID() |
Returns this locale’s language ID. | craft\i18n\Locale |
getMonthName() |
Returns a localized month name. | craft\i18n\Locale |
getMonthNames() |
Returns all of the localized month names. | craft\i18n\Locale |
getName() |
Returns the locale name in a given language. | craft\i18n\Locale |
getNativeName() |
Returns the locale name in its own language. | craft\i18n\Locale |
getNumberPattern() |
Returns a number pattern used by this locale. | craft\i18n\Locale |
getNumberSymbol() |
Returns a number symbol used by this locale. | craft\i18n\Locale |
getOrientation() |
Returns the language’s orientation (ltr or rtl). | craft\i18n\Locale |
getPMName() |
Returns the "PM" name for this locale. | craft\i18n\Locale |
getScriptID() |
Returns this locale’s script ID. | craft\i18n\Locale |
getTerritoryID() |
Returns this locale’s territory ID. | craft\i18n\Locale |
getTextAttribute() |
Returns a text attribute used by this locale. | craft\i18n\Locale |
getTimeFormat() |
Returns the localized ICU time format. | craft\i18n\Locale |
getWeekDayName() |
Returns a localized day of the week name. | craft\i18n\Locale |
getWeekDayNames() |
Returns all of the localized day of the week names. | craft\i18n\Locale |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | yii\base\BaseObject |
Constant | Value | Description | Defined By |
---|---|---|---|
ATTR_CURRENCY_CODE |
5 | craft\i18n\Locale | |
ATTR_DEFAULT_RULESET |
6 | craft\i18n\Locale | |
ATTR_NEGATIVE_PREFIX |
2 | craft\i18n\Locale | |
ATTR_NEGATIVE_SUFFIX |
3 | craft\i18n\Locale | |
ATTR_PADDING_CHARACTER |
4 | craft\i18n\Locale | |
ATTR_POSITIVE_PREFIX |
0 | craft\i18n\Locale | |
ATTR_POSITIVE_SUFFIX |
1 | craft\i18n\Locale | |
ATTR_PUBLIC_RULESETS |
7 | craft\i18n\Locale | |
FORMAT_ICU |
'icu' | craft\i18n\Locale | |
FORMAT_JUI |
'jui' | craft\i18n\Locale | |
FORMAT_PHP |
'php' | craft\i18n\Locale | |
LENGTH_ABBREVIATED |
'abbreviated' | craft\i18n\Locale | |
LENGTH_FULL |
'full' | craft\i18n\Locale | |
LENGTH_LONG |
'long' | craft\i18n\Locale | |
LENGTH_MEDIUM |
'medium' | craft\i18n\Locale | |
LENGTH_SHORT |
'short' | craft\i18n\Locale | |
STYLE_CURRENCY |
2 | craft\i18n\Locale | |
STYLE_DECIMAL |
1 | craft\i18n\Locale | |
STYLE_PERCENT |
3 | craft\i18n\Locale | |
STYLE_SCIENTIFIC |
4 | craft\i18n\Locale | |
SYMBOL_CURRENCY |
8 | craft\i18n\Locale | |
SYMBOL_DECIMAL_SEPARATOR |
0 | craft\i18n\Locale | |
SYMBOL_DIGIT |
5 | craft\i18n\Locale | |
SYMBOL_EXPONENTIAL |
11 | craft\i18n\Locale | |
SYMBOL_GROUPING_SEPARATOR |
1 | craft\i18n\Locale | |
SYMBOL_INFINITY |
14 | craft\i18n\Locale | |
SYMBOL_INTL_CURRENCY |
9 | craft\i18n\Locale | |
SYMBOL_MINUS_SIGN |
6 | craft\i18n\Locale | |
SYMBOL_MONETARY_GROUPING_SEPARATOR |
17 | craft\i18n\Locale | |
SYMBOL_MONETARY_SEPARATOR |
10 | craft\i18n\Locale | |
SYMBOL_NAN |
15 | craft\i18n\Locale | |
SYMBOL_PAD_ESCAPE |
13 | craft\i18n\Locale | |
SYMBOL_PATTERN_SEPARATOR |
2 | craft\i18n\Locale | |
SYMBOL_PERCENT |
3 | craft\i18n\Locale | |
SYMBOL_PERMILL |
12 | craft\i18n\Locale | |
SYMBOL_PLUS_SIGN |
7 | craft\i18n\Locale | |
SYMBOL_SIGNIFICANT_DIGIT |
16 | craft\i18n\Locale | |
SYMBOL_ZERO_DIGIT |
4 | craft\i18n\Locale |
Property Details
$id
public property
#
The locale ID.
public string, null $id = null
Method Details
__construct()
public method
#
Constructor.
public void __construct ( \craft\i18n\string $id, array $config = [] )
$id |
string | The locale ID. |
$config |
array | Name-value pairs that will be used to initialize the object properties. |
throws | yii\base\InvalidArgumentException | If $id is an unsupported locale. |
---|
__toString()
public method
#
Use the ID as the string representation of locales.
public string __toString ( )
getAMName()
public method
#
Returns the "AM" name for this locale.
public string getAMName ( )
return | string | The "AM" name. |
---|
getCurrencySymbol()
public method
#
Returns this locale’s symbol for a given currency.
public string getCurrencySymbol ( \craft\i18n\string $currency )
$currency |
string | The 3-letter ISO 4217 currency code indicating the currency to use. |
return | string | The currency symbol. |
---|
getDateFormat()
public method
#
Returns the localized ICU date format.
public string getDateFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )
$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 |
return | string | The localized ICU date format. |
---|
getDateTimeFormat()
public method
#
Returns the localized ICU date + time format.
public string getDateTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )
$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 |
return | string | The localized ICU date + time format. |
---|
getDisplayName()
public method
#
Returns the locale name in a given language.
public string getDisplayName ( \craft\i18n\string $inLocale = null )
$inLocale |
string, null |
getFormatter()
public method
#
Returns a craft\i18n\Formatter for this locale.
public craft\i18n\Formatter getFormatter ( )
return | craft\i18n\Formatter | A formatter for this locale. |
---|
getId()
public method
#
Deprecated in 3.0. Use id instead.
Returns the locale ID.
public string getId ( )
getLanguageID()
public method
#
Returns this locale’s language ID.
public string getLanguageID ( )
return | string | This locale’s language ID. |
---|
getMonthName()
public method
#
Returns a localized month name.
public string getMonthName ( \craft\i18n\int $month, \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )
$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. |
return | string | The localized month name. |
---|
getMonthNames()
public method
#
Returns all of the localized month names.
public array getMonthNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )
$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. |
return | array | The localized month names. |
---|
getName()
public method
#
Deprecated in 3.0. Use getDisplayName() instead.
Returns the locale name in a given language.
public string, null getName ( \craft\i18n\string $targetLocaleId = null )
$targetLocaleId |
string, null |
getNativeName()
public method
#
Deprecated in 3.0. Use getDisplayName() instead.
Returns the locale name in its own language.
public string, false getNativeName ( )
getNumberPattern()
public method
#
Returns a number pattern used by this locale.
public string, null getNumberPattern ( \craft\i18n\int $style )
$style |
integer | The pattern style to return. Accepted values: Locale::STYLE_DECIMAL, ::STYLE_CURRENCY, ::STYLE_PERCENT, ::STYLE_SCIENTIFIC |
return | string, null | The pattern |
---|
getNumberSymbol()
public method
#
Returns a number symbol used by this locale.
public string, null getNumberSymbol ( \craft\i18n\int $symbol )
$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 |
return | string, null | The symbol. |
---|
getOrientation()
public method
#
Returns the language’s orientation (ltr or rtl).
public string getOrientation ( )
return | string | The language’s orientation. |
---|
getPMName()
public method
#
Returns the "PM" name for this locale.
public string getPMName ( )
return | string | The "PM" name. |
---|
getScriptID()
public method
#
Returns this locale’s script ID.
A script ID consists of only the last four characters after a dash in the locale ID.
public string, null getScriptID ( )
return | string, null | The locale’s script ID, if it has one. |
---|
getTerritoryID()
public method
#
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.
public string, null getTerritoryID ( )
return | string, null | The locale’s territory ID, if it has one. |
---|
getTextAttribute()
public method
#
Returns a text attribute used by this locale.
public string, null getTextAttribute ( \craft\i18n\int $attribute )
$attribute |
integer | The attribute to return. Values: Locale:: |
return | string, null | The attribute. |
---|
getTimeFormat()
public method
#
Returns the localized ICU time format.
public string getTimeFormat ( \craft\i18n\string $length = null, \craft\i18n\string $format = self::FORMAT_ICU )
$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 |
return | string | The localized ICU time format. |
---|
getWeekDayName()
public method
#
Returns a localized day of the week name.
public string getWeekDayName ( \craft\i18n\int $day, \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )
$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. |
return | string | The localized day of the week name. |
---|
getWeekDayNames()
public method
#
Returns all of the localized day of the week names.
public array getWeekDayNames ( \craft\i18n\string $length = null, \craft\i18n\bool $standAlone = true )
$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. |
return | array | The localized day of the week names. |
---|