Final Class Yiisoft\Translator\Message\Gettext\MessageSource
| Inheritance | Yiisoft\Translator\Message\Gettext\MessageSource |
|---|---|
| Implements | Yiisoft\Translator\MessageReaderInterface |
Public Methods
Method Details
| public mixed __construct ( string $path ) | ||
| $path | string |
The directory path. |
public function __construct(
private string $path
) {
if (!is_dir($path)) {
throw new RuntimeException(sprintf('Directory "%s" does not exist.', $path));
}
}
We use first parameter as $n for plurals if its value type is int.
| public getMessage ( string $id, string $category, string $locale, array $parameters = [] ) | ||
| $id | string | |
| $category | string | |
| $locale | string | |
| $parameters | array | |
public function getMessage(string $id, string $category, string $locale, array $parameters = []): ?string
{
$this->bindDomain($category);
$this->setLocale($locale);
$n = current($parameters);
if (is_int($n) === false) {
return dgettext($category, $id);
}
return dngettext($category, $id, $id, $n);
}
Signup or Login in order to comment.