sboden/extractor

从源代码中提取翻译

2.1.2 2024-04-30 20:02 UTC

This package is auto-updated.

Last update: 2024-09-30 21:00:36 UTC


README

Latest Version Total Downloads

从源代码中提取翻译消息

安装

通过 Composer

$ composer require php-translation/extractor

使用方法

$extractor = new Extractor();

// Create an extractor for PHP files
$fileExtractor = new PHPFileExtractor();

// Add visitors
$fileExtractor->addVisitor(new ContainerAwareTrans());
$fileExtractor->addVisitor(new ContainerAwareTransChoice());
$fileExtractor->addVisitor(new FlashMessage());
$fileExtractor->addVisitor(new FormTypeChoices());

// Add the file extractor to Extactor
$extractor->addFileExtractor($fileExtractor);

// Define where the source code is
$finder = new Finder();
$finder->in('/foo/bar');

//Start extracting files
$sourceCollection = $extractor->extract($finder);

发现了一个问题吗?

是我们没有提取的内容吗?请将其添加为测试。在 tests/Resources/Github/Issue_XX.php 中添加一个新文件,包含您的示例代码,然后编辑 AllExtractorsTest 以确保找到翻译键

// ...
$this->translationExists($sc, 'trans.issue_xx');