$t->ok($e instanceof sfI18nExtractorInterface, 'sfI18nPhpExtractor implements the sfI18nExtractorInterface interface'); // ->extract(); $t->diag('->extract()'); $content = <<<EOF __('bar') <?php __('foo') ?> <?php __('I\'m "happy"') ?> <?php __("I'm very \"happy\"") ?> <?php __("I\\'m so \"happy\"") ?> EOF; $t->is($e->extract($content), array('foo', 'I\'m "happy"', 'I\'m very "happy"', 'I\\\'m so "happy"'), '->extract() extracts strings from PHP files'); $content = <<<EOF <?php format_number_choice('foo') ?> EOF; $t->is($e->extract($content), array('foo'), '->extract() takes into account the format_number_choice() helper'); $content = <<<EOF <?php \$this->getContext()->getI18N()->__('foo') ?> EOF; $t->is($e->extract($content), array('foo'), '->extract() takes into account calls in an action file'); $content = <<<EOF <?php
/** * Extracts i18n strings from PHP files. * * @param string $dir The PHP full path name */ protected function extractFromPhpFiles($dir) { $phpExtractor = new sfI18nPhpExtractor(); $files = sfFinder::type('file')->name('*.php'); $messages = array(); foreach ($files->in($dir) as $file) { $messages = array_merge($messages, $phpExtractor->extract(file_get_contents($file))); } $this->updateMessages($messages); }