-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi Oscar,
this is the case, comment extraction does not work:
<?php
require 'vendor/autoload.php';
use Gettext\Scanner\PhpScanner;
use Gettext\Translations;
$phpScanner = new PhpScanner(
Translations::create('default'),
Translations::create('admin'),
);
$phpScanner->setFunctions([
'__' => 'gettext',
'd__' => 'dgettext',
]);
$phpScanner->ignoreInvalidFunctions(true);
$phpScanner->setDefaultDomain('default');
$phpScanner->extractCommentsStartingWith('PREV:', 'Prev:', 'prev:');
$phpScanner->scanFile('class.php');
echo '<pre>' . PHP_EOL;
print_r($phpScanner->getTranslations());
And this is the class.php
<?php
/* PREV: Extracted comment 1 */
$arg = [__('String with extracted comment 1')];
$args = [];
$args = array_merge($args, [
'title' => /* PREV: Extracted comment 2 */ __('Contact'),
'noscript' => [
/* PREV: Omitted commnet above 1 */
Flash::INFO => [__('String with no comment extracted despite it has one.')]
],
'breadcrumb' => [
['text' => /* PREV: Extracted comment 3 */ d__('admin', 'String with extracted comment 3'), 'link' => get_homepage_url()],
],
'metatags' => new Meta([
/* PREV: Omitted commnet above 2 */
'description' => __('Another string with no comment extracted despite it has one.'),
]),
]
);
Is this a bug or am I doing something wrong?
NOTE: PREV in this case means "previous original"
Metadata
Metadata
Assignees
Labels
No labels