class MessageFormatter (View source)

Methods

__construct(string $locale, string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Constructs a new Message Formatter

static MessageFormatter|null
create(string $locale, string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Constructs a new Message Formatter

string|false
format(array $values)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format the message

static string|false
formatMessage(string $locale, string $pattern, array $values)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Quick format message

array|false
parse(string $string)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse input string according to pattern

static array|false
parseMessage(string $locale, string $pattern, string $message)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Quick parse input string

bool
setPattern(string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set the pattern used by the formatter

string|false
getPattern()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the pattern used by the formatter

string
getLocale()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the locale for which the formatter was created.

int
getErrorCode()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the error code from last operation

string
getErrorMessage()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the error text from the last operation

Details

__construct(string $locale, string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Constructs a new Message Formatter

Parameters

string $locale

The locale to use when formatting arguments

string $pattern

The pattern string to stick arguments into. The pattern uses an 'apostrophe-friendly' syntax; it is run through umsg_autoQuoteApostrophe before being interpreted.

Exceptions

IntlException

static MessageFormatter|null create(string $locale, string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Constructs a new Message Formatter

Parameters

string $locale

The locale to use when formatting arguments

string $pattern

The pattern string to stick arguments into. The pattern uses an 'apostrophe-friendly' syntax; it is run through umsg_autoQuoteApostrophe before being interpreted.

Return Value

MessageFormatter|null

The formatter object

string|false format(array $values)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format the message

Parameters

array $values

Arguments to insert into the format string

Return Value

string|false

The formatted string, or FALSE if an error occurred

static string|false formatMessage(string $locale, string $pattern, array $values)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Quick format message

Parameters

string $locale

The locale to use for formatting locale-dependent parts

string $pattern

The pattern string to insert things into. The pattern uses an 'apostrophe-friendly' syntax; it is run through umsg_autoQuoteApostrophe before being interpreted.

array $values

The array of values to insert into the format string

Return Value

string|false

The formatted pattern string or FALSE if an error occurred

array|false parse(string $string)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse input string according to pattern

Parameters

string $string

The string to parse

Return Value

array|false

An array containing the items extracted, or FALSE on error

static array|false parseMessage(string $locale, string $pattern, string $message)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Quick parse input string

Parameters

string $locale

The locale to use for parsing locale-dependent parts

string $pattern

The pattern with which to parse the value.

string $message

The string to parse, conforming to the pattern.

Return Value

array|false

An array containing items extracted, or FALSE on error

bool setPattern(string $pattern)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set the pattern used by the formatter

Parameters

string $pattern

The pattern string to use in this message formatter. The pattern uses an 'apostrophe-friendly' syntax; it is run through umsg_autoQuoteApostrophe before being interpreted.

Return Value

bool

TRUE on success or FALSE on failure.

string|false getPattern()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the pattern used by the formatter

Return Value

string|false

The pattern string for this message formatter

string getLocale()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the locale for which the formatter was created.

Return Value

string

The locale name

int getErrorCode()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the error code from last operation

Return Value

int

The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.

string getErrorMessage()

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get the error text from the last operation

Return Value

string

Description of the last error.