-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Command translation:update
doesn't take into account domain
#42285
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
Comments
I see you can pass |
Hi @JohJohan that argument should just filter the translations of the specified domain. |
Generally, the PHP extractor should be able to extract domains too. Can you create a small example application that allows to reproduce the behaviour that you experience? |
Of course! This is a really simple project, if you type (it should be inside validators) Thanks. Project: translation_bug.zip |
Thank you that helped a lot! I think the extractor is not able to parse the domain properly because of the use of the If you change the line to something like this everything is working as expected for me: $message = $this->translator->trans('This is the string I would like to translate', [], 'validators'); |
Yes, I can confirm that if I remove |
Hey, thanks for your report! |
I can confirm that issue is still present for php extractor in 5.4.x. |
/cc @welcoMattic |
After discussion with @nicolas-grekas and @stof IRL, we concluded that is much more complicated to fix this issue (and not break concatenation of variable and string). So we decided to won't fix for now. But, we noticed that we do not support named arguments in PhpExtractor. To do it, we need to write a new Extractor based on AST. Once this new Extractor will ne written, we may plan to support inline variable assignation. |
This PR was merged into the 6.2 branch. Discussion ---------- [Translation] Add `PhpAstExtractor` | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #44899, #42285, #45972, #45039 | License | MIT | Doc PR | symfony/symfony-docs#17369 After discussions with `@stof` and `@nicolas`-grekas at SymfonyLive Paris 2022, it appears clear that we need a brand new PhpExtractor in Translation to support various syntax, especially PHP8 new syntax (named arguments for example). In order to make this new extractor sustainable, performant and maintainable, it must be based on AST. That's why this PR adds a new optional dependency on [nikic/php-parser](https://github.com/nikic/PHP-Parser). The tests suite is the same as PhpExtractorTest, in addition to new cases for newly supported syntax. NB: I was inspired by https://github.com/php-translation/extractor design, with adaptations for Symfony. To-do: - [x] As suggested by `@Nyholm`, take a look at https://github.com/php-translation/extractor - [x] Fix #45039 (could be achieved easily with AST tree) Commits ------- 5d4a81f Add PhpAstExtractor
Hello, I am using Symfony 4.4 and I just realized that when using the following command:
php bin/console translation:update --force en
The command doesn't take into account the specified domain, for example:
The string
This is the string I would like to translate
should be inserted in the filevalidators.en.xlf
but it's written in themessages.en.xlf
file.Thanks!
The text was updated successfully, but these errors were encountered: