-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Translation] Extract translation IDs from all of src #40229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think this should be treated as a new feature, yes.
What about adding a new option in related commands to extract also from one specific directory or file? For example, with such option we could add the
The option could accept an array of paths too. What do you think? |
Have I missed something or |
Thinking about DX I think having Regarding adding that as an option does solve my concern around making this work for teams that use non-standard directories, but I think adding that should be in a separate PR as they are different features. If it turns out that including |
Support was added to |
I had a chance to dig into this and it doesn't appear that this is a potential workaround. |
@@ -140,6 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |||
$transPaths[] = $this->defaultTransPath; | |||
} | |||
$viewsPaths = $this->viewsPaths; | |||
$viewsPaths[] = $kernel->getProjectDir().'/src'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would create a new array as src/
does not contain views, something like $codePaths
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabpot just to provide context, currently if you inject TranslatorInterface
, those classes get added to $viewPaths
even though it doesn't contain any templates.
Here's an example dump:
^ array:16 [
0 => "public"
1 => "/var/www/html/vendor/symfony/twig-bridge/Resources/views/Email"
2 => "/var/www/html/vendor/symfony/twig-bridge/Resources/views/Form"
3 => "/var/www/html/vendor/symfony/framework-bundle/Command/TranslationDebugCommand.php"
4 => "/var/www/html/vendor/symfony/form/Extension/Core/Type/ColorType.php"
5 => "/var/www/html/vendor/symfony/form/Extension/Core/Type/TransformationFailureExtension.php"
6 => "/var/www/html/vendor/symfony/form/Extension/Validator/Type/FormTypeValidatorExtension.php"
7 => "/var/www/html/vendor/symfony/form/Extension/Validator/Type/UploadValidatorExtension.php"
8 => "/var/www/html/vendor/symfony/form/Extension/Csrf/Type/FormTypeCsrfExtension.php"
9 => "/var/www/html/vendor/symfony/validator/ValidatorBuilder.php"
10 => "/var/www/html/vendor/symfony/framework-bundle/CacheWarmer/TranslationsCacheWarmer.php"
11 => "/var/www/html/vendor/symfony/translation/DataCollector/TranslationDataCollector.php"
12 => "/var/www/html/src/Controller/SecurityController.php"
13 => "/var/www/html/vendor/symfony/form/Extension/Core/Type/FileType.php"
14 => "/var/www/html/vendor/symfony/twig-bridge/Extension/TranslationExtension.php"
15 => "/var/www/html/vendor/symfony/twig-bridge/Extension/FormExtension.php"
]
Can you confirm if we should keep it this way or if we should add $codePaths
and then if we do add $codePaths
would we just use it for adding the src
folder or would we move some of these files into $codePaths
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say that the issue is the name $viewPaths
. When the variable was first introduced, the PhpExtractor was targetting only PHP templates, not other usages of the translator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vars have been renamed to codePaths
As long as |
860cc41
to
f693ab3
Compare
f693ab3
to
b02ae50
Compare
Thank you @natewiebe13. |
…ebe13) This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- Update docs relating to translation extraction Update translation extraction docs based on changes from symfony/symfony#40229 Fixes #15061 Commits ------- 77089fa Update docs relating to translation extraction
This is a hack to scan froms for translation while waiting for symfony/symfony#40229 to be released. See symfony/symfony#35082 (comment)
This is a hack to scan froms for translation while waiting for symfony/symfony#40229 to be released. See symfony/symfony#35082 (comment)
This PR allows extracting (
bin/console translation:update
) and debugging (bin/console debug:translation
) translations using Translatable messages.Currently we only check classes that include the
TranslatorInterface
, but this no longer covers all instances of this.Current considerations:
/src
?/src
takes these operations from about 3s to 5s, but I feel like this is reasonable considering this command isn't likely called constantly. I can provide more accurate stats as requested.