Final Class Yiisoft\Translator\IntlMessageFormatter
| Inheritance | Yiisoft\Translator\IntlMessageFormatter |
|---|---|
| Implements | Yiisoft\Translator\MessageFormatterInterface |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Translator\IntlMessageFormatter | |
| format() | This method uses {{@see MessageFormatter::format()}} | Yiisoft\Translator\IntlMessageFormatter |
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;
}
Signup or Login in order to comment.