-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed as not planned
Closed as not planned
Copy link
Description
Symfony version(s) affected
7.1
Description
Documentation mentions
The translation:extract command looks for missing translations in:
...
- Any PHP file/class that injects or autowires the translator service and makes calls to the trans() method..
...
When bundle is specified, this does not work as stated. Following line limits path to extract texts to only bundle template folder:
$codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; |
I did not find any other official way to extract PHP code translations from bundle. I believe at least PHP files using translator
service should be included in extracted bundle translations.
How to reproduce
php bin/console translation:extract --force fr AcmeBundle
Only translations from templates (AcmeBundle/templates
) are extracted. No PHP trans()
calls are extracted.
Possible Solution
Use result from $this->getRootCodePaths($kernel)
and leave all files from given bundle.
symfony/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
Lines 149 to 159 in 29b00c2
$codePaths = $this->getRootCodePaths($kernel); | |
$currentName = 'default directory'; | |
// Override with provided Bundle info | |
if (null !== $input->getArgument('bundle')) { | |
try { | |
$foundBundle = $kernel->getBundle($input->getArgument('bundle')); | |
$bundleDir = $foundBundle->getPath(); | |
$transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations']; | |
$codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; |
Additional Context
No response
MrkMrk00, davidvancl, prokopwpj and Tobo7