Closed mihaikelemen closed 4 years ago
Ok, I guess this is a bug introduced in #223 @briedis could you please fix this? I don't have free time these days.
I'll check it out
@mihaikelemen Could you provide more info?
By default, __ should have only one argument:
Hi @briedis ,
Sorry for the late response. I'm using this approach with the second argument for quite a while, based on the docs (see bellow). It is a handful approach.
Mihai
This the actual code (part of it) that generates the po file for a given locale (in this case ro_RO
)
$files->files()
->name('/(.*)\.(tpl|php)/')
->depth('>=1')
->in($dirs);
$translations = new Translations();
$translations->setLanguage('ro_RO');
$translations->setDomain('messages');
# locale directory path
$dir = sprintf('%s%s/', $config->get('environment.locales'), 'ro_RO');
$potfile = sprintf('%s%s.po', $dir, $translations->getDomain());
if (!$filesystem->exists($dir)) {
$filesystem->mkdir($dir, 0755);
$filesystem->touch($potfile);
}
foreach ($files as $file) {
$translations->addFromPhpCodeFile($file->getPathname());
}
if ($filesystem->exists($potfile)) {
$translations->mergeWith(Translations::fromPoFile($potfile));
}
$translations->toPoFile($potfile);
Sorry @mihaikelemen for the delay, but I managed to run into this issue on my own too. A PR is created for the v4 branch. Actually the code to reproduce the issue was much simpler - just scan a file for one domain, but the file contains a single pgettext call without any strings from the domain you are searching for.
Hi @briedis , Thanks for your response. For now I'm using 4.6.3 until otherwise; eventually I will upgrade my code to run with the newer v5 branch.
Mihai
Scanning PHP code fails on v4.7 for the this type of translation
__("Foo %s", "bar")
This is working on v4.6.3