Final Class Yiisoft\TranslatorExtractor\Command\ExtractCommand
| Inheritance | Yiisoft\ |
|---|
Console command that allows extracting translator IDs from files.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\ |
|
| execute() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $extractor | Yiisoft\ |
|
public function __construct(private Extractor $extractor)
{
parent::__construct();
}
| protected void configure ( ) |
protected function configure(): void
{
$this
->addOption('languages', 'L', InputOption::VALUE_OPTIONAL, 'Comma separated list of languages to write message sources for. By default it is `en`.', 'en')
->addOption('category', 'C', InputOption::VALUE_OPTIONAL, 'Default message category to use when category is not set.', $this->defaultCategory)
->addOption('except', 'E', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Exclude path from extracting.', [])
->addOption('only', 'O', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'Use the only specified path for extracting.', [])
->addArgument('path', InputArgument::OPTIONAL, 'Path for extracting message IDs.')
->setHelp('This command Extracts translator IDs from files within a given path.');
}
| protected integer execute ( \ | ||
| $input | \ |
|
| $output | \ |
|
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string */
$path = $input->getArgument('path') ?? getcwd();
/** @var string */
$languages = $input->getOption('languages');
/** @var string */
$category = $input->getOption('category');
/** @var string[] */
$except = $input->getOption('except');
/** @var string[] */
$only = $input->getOption('only');
/** @var string[] */
$languagesList = explode(',', $languages);
$this->extractor->setExcept($except);
$this->extractor->setOnly($only);
$this->extractor->process($path, $category, $languagesList, $output);
return 0;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.