Final Class Yiisoft\Translator\Extractor\ContentParser
| Inheritance | Yiisoft\Translator\Extractor\ContentParser |
|---|
Extracts translation keys from a string given.
Public Methods
Method Details
| public mixed __construct ( string $defaultCategory, string|null $translator = null ) | ||
| $defaultCategory | string |
Name of the category to use when no category is specified. |
| $translator | string|null |
A string containing a method call that translates the message. If not specified, "->translate" is assumed. |
public function __construct(private string $defaultCategory, ?string $translator = null)
{
$this->setTranslator($translator ?? $this->translatorCall);
}
| public array extract ( string $content ) | ||
| $content | string |
Code to extract translation keys from. |
| return | array |
Extracted messages. |
|---|---|---|
public function extract(string $content): array
{
$this->skippedLines = [];
$tokens = token_get_all($content);
return $this->extractMessagesFromTokens($tokens);
}
| public array getSkippedLines ( ) | ||
| return | array |
Lines that were skipped during parsing. The format is:
|
|---|---|---|
public function getSkippedLines(): array
{
return $this->skippedLines;
}
| public boolean hasSkippedLines ( ) | ||
| return | boolean |
Whether there are skipped lines. |
|---|---|---|
public function hasSkippedLines(): bool
{
return !empty($this->skippedLines);
}
| public void setDefaultCategory ( string $defaultCategory ) | ||
| $defaultCategory | string |
Name of the category to use when no category is specified. |
public function setDefaultCategory(string $defaultCategory): void
{
$this->defaultCategory = $defaultCategory;
}
Signup or Login in order to comment.