Skip to content

Repository files navigation

Translation extractor

Latest VersionTotal Downloads

Extract translation messages from source code

Install

Via Composer:

$ composer require php-translation/extractor

Usage

$extractor = newExtractor();
// Create an extractor for PHP files$fileExtractor = newPHPFileExtractor();
// Add visitors$fileExtractor->addVisitor(newContainerAwareTrans());
$fileExtractor->addVisitor(newContainerAwareTransChoice());
$fileExtractor->addVisitor(newFlashMessage());
$fileExtractor->addVisitor(newFormTypeChoices());
// Add the file extractor to Extactor$extractor->addFileExtractor($fileExtractor);
// Define where the source code is$finder = newFinder();
$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');

About

Extracts translation strings from source code

Resources

Stars

128 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages