sooyoos / extractor
从源代码中提取翻译
2.0.2
2020-06-10 08:44 UTC
Requires
- php: ^7.2
- doctrine/annotations: ^1.2
- nikic/php-parser: ^3.0 || ^4.0
- symfony/finder: ^3.4 || ^4.3 || ^5.0
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- knplabs/knp-menu: ^3.1
- phpunit/phpunit: ^8.4
- symfony/phpunit-bridge: ^5.0
- symfony/translation: ^3.4 || ^4.3 || ^5.0
- symfony/twig-bridge: ^3.4 || ^4.3 || ^5.0
- symfony/validator: ^3.4 || ^4.3 || ^5.0
README
从源代码中提取翻译消息
安装
通过 Composer
$ composer require php-translation/extractor
用法
$extractor = new Extractor(); // Create 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');