Final Class Yiisoft\Translator\IntlMessageFormatter
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| format() | This method uses {{@see MessageFormatter::format()}} | Yiisoft\ |
Method Details
| public mixed __construct ( ) |
public function __construct()
{
if (!extension_loaded('intl')) {
throw new RuntimeException(
'In order to use intl message formatter, intl extension must be installed and enabled.',
);
}
}
This method uses {{@see MessageFormatter::format()}}
| public string format ( string $message, array $parameters, string $locale ) | ||
| $message | string | |
| $parameters | array | |
| $locale | string | |
public function format(string $message, array $parameters, string $locale): string
{
if ($parameters === []) {
return $message;
}
$formatter = new MessageFormatter($locale, $message);
$result = $formatter->format($parameters);
if ($result === false) {
return $message;
}
return $result;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.