sboden / extractor
Extract translations form the source code
2.1.2
2024-04-30 20:02 UTC
Requires
- php: ^7.2 || ^8.0
- doctrine/annotations: ^1.7 || ^2.0
- nikic/php-parser: ^3 || ^4 || ^5
- symfony/finder: ^3 || ^4 || ^5 || ^6
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- knplabs/knp-menu: ^3.1
- symfony/phpunit-bridge: ^5.0 || ^6.0
- symfony/translation: ^3.4 || ^4.4 || ^5.0 || ^6.0
- symfony/twig-bridge: ^3.4 || ^4.4 || ^5.0 || ^6.0
- symfony/validator: ^3.4 || ^4.4 || ^5.0 || ^6.0
This package is auto-updated.
Last update: 2025-03-29 01:08:34 UTC
README
Extract translation messages from source code
Install
Via Composer:
$ composer require php-translation/extractor
Usage
$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);
Found an issue?
Is it something we do not extract? Please add it as a test. Add a new file with your example code in
tests/Resources/Github/Issue_XX.php
, then edit the AllExtractorsTest
to make sure the translation
key is found:
// ... $this->translationExists($sc, 'trans.issue_xx');