Final Class Yiisoft\TranslatorExtractor\CategorySource
| Inheritance | Yiisoft\ |
|---|
Represents message category for reading and writing messages.
Public Methods
Method Details
| public mixed __construct ( string $name, \ | ||
| $name | string |
Category name. |
| $reader | \ |
|
| $writer | \ |
|
public function __construct(
private string $name,
private MessageReaderInterface $reader,
private MessageWriterInterface $writer,
) {
if (!preg_match('/^[a-z0-9_-]+$/i', $name)) {
throw new RuntimeException(
'Category name is invalid. Only letters, numbers, dash, and underscore are allowed.',
);
}
}
| public string getName ( ) | ||
| return | string |
Category name. |
|---|---|---|
public function getName(): string
{
return $this->name;
}
| public array readMessages ( string $category, string $locale ) | ||
| $category | string |
Category of messages to get. |
| $locale | string |
Locale of messages to get. |
| return | array |
All messages from category. The format is
the same as in {@see \ |
|---|---|---|
public function readMessages(string $category, string $locale): array
{
return $this->reader->getMessages($category, $locale);
}
See also \
| public void writeMessages ( string $category, string $locale, array $messages ) | ||
| $category | string |
Category to write messages to. |
| $locale | string |
Locale to write messages for. |
| $messages | array |
Messages to write. |
public function writeMessages(string $category, string $locale, array $messages): void
{
$this->writer->write($category, $locale, $messages);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.