0 follower

Final Class Yiisoft\Translator\Message\Gettext\MessageSource

InheritanceYiisoft\Translator\Message\Gettext\MessageSource
ImplementsYiisoft\Translator\MessageReaderInterface

Method Details

Hide inherited methods

__construct() public method

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));
    }
}

            
getMessage() public method

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);
}

            
getMessages() public method

public array getMessages ( string $category, string $locale )
$category string
$locale string

                public function getMessages(string $category, string $locale): array
{
    throw new RuntimeException('Unable to get all messages from gettext.');
}