You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure, maybe this issue should be submitted to nikic/php-parser repo instead. I use own Translator helper class with static methods and I cannot extract messages from it method invocations.
Translator helper class:
useGettext\Loader\PoLoader;
useGettext\Translation;
finalclass Translator
{
/** @var Gettext\Loader\LoaderInterface|null */protectedstatic$loader;
/** @var Gettext\Translations|null */protectedstatic$translations;
/** * Loads translations from PO file with php/gettext package. * @ref https://github.com/php-gettext/Gettext * * @param string $filePath Path to PO file */publicstaticfunctionloadPo(string$filePath)
{
if (!static::$loader) {
static::$loader = newPoLoader();
}
static::$translations = static::$loader->loadFile($filePath);
}
/** * Translates message. * * @param string $msg Original message * * @return string Localized message or original if doesn't exist in PO file */publicstaticfunctiontranslate(string$msg): string
{
$t = static::$translations->find(null, $msg);
if (
$tinstanceof Translation
&& $t->isTranslated()
) {
return$t->getTranslation();
}
return$msg;
}
}
scanner configuration:
//Create a new scanner, adding a translation for each domain we want to get:$phpScanner = newPhpScanner(
Translations::create('domain')
);
$phpScanner->setFunctions(
array_merge(
$phpScanner->getFunctions(),
// none of following works
['Translator::translate' => 'gettext'],
['::translate' => 'gettext'],
['translate' => 'gettext']
)
);
scanned file example:
Translator::loadPo('../locale/en/LC_MESSAGES/domain.po');
// i18n: 'Hello World' should be extracted$msg = Translator::translate('Hello World');
echo$msg;
// po file saving omitted
The text was updated successfully, but these errors were encountered:
I'm not sure, maybe this issue should be submitted to nikic/php-parser repo instead. I use own
Translator
helper class with static methods and I cannot extract messages from it method invocations.Translator
helper class:scanner configuration:
scanned file example:
The text was updated successfully, but these errors were encountered: