• Stars
    star
    123
  • Rank 289,277 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Extracts translation strings from source code

Translation extractor

Latest Version Total Downloads

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');