Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Allow to specify a domain when updating translations#19325
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[FrameworkBundle] Allow to specify a domain when updating translations#19325
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| } | ||
| $writer->writeTranslations($operation->getResult(),$input->getOption('output-format'),array('path' =>$bundleTransPath,'default_locale' =>$this->getContainer()->getParameter('kernel.default_locale'))); | ||
| $writer->writeTranslations($operation->getResult($input->getOption('domain')),$input->getOption('output-format'),array('path' =>$bundleTransPath,'default_locale' =>$this->getContainer()->getParameter('kernel.default_locale'))); |
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.
but getResult takes no arguments, or did I miss something?
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.
@nicolas-grekas I added an optional one in src/Symfony/Component/Translation/Catalogue/AbstractOperation.php
antograssiot commentedJul 17, 2016
ping@nicolas-grekas I've updated as requested. |
| * {@inheritdoc} | ||
| */ | ||
| publicfunctiongetResult() | ||
| publicfunctiongetResult($domain =null) |
nicolas-grekasJul 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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'm not comfortable with this change. The $operation should already have filtered domains.
I see two alternatives: addsetDomains() onAbstractOperation, or add a$domains argument toMessageCatalogue to make it filter messages it can contain. A third alt. would be to filter at the loader/extractor level, but they look too specific for this. WDYT?
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.
Or fourth way, maybe the less intrusive one: filter the result itself?
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 went with adding setDomains(). but I can still try to update if you want.
Also do you want me to squash the 2 commits ?
antograssiot commentedJul 17, 2016
@nicolas-grekas the tests are passing locally but fails with low deps on travis due to composer issue. This doesn't seems related to my change, am I right ? |
| // Exit if no messages found. | ||
| if (!count($operation->getDomains())) { | ||
| if (!count($domains)) { |
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.
Change not needed anymore, same below
antograssiotJul 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
that was still to avoid some function call but I can remove it
nicolas-grekas commentedJul 17, 2016
FrameworkBundle now needs Translation 3.2, that's why lowest tests are failing |
| $domain =$input->getOption('domain'); | ||
| if (null !==$domain) { | ||
| $domains =array_intersect($domains,array($domain)); |
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 don't think we need this line: when the option is set, let's call setDomains with it
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 may be wrong though here :)
antograssiotJul 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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'll leave thearray_intersect() because if you use for example--domain nonexisting
Then you'll get an empty array when callinggetDomains() and the command will exit (L155-158)
antograssiot commentedJul 17, 2016
@nicolas-grekas thanks for your explanation on the Travis build and your review. |
nicolas-grekas commentedJul 17, 2016
Looks like your target can be achieved with changing the translation component: |
antograssiot commentedJul 17, 2016
Nicolas I'm sorry I don't get your comment. You tm branch is not up to date with mine but I tested it again in an app and it seems to work as expected. |
nicolas-grekas commentedJul 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@antograssiot if you're fine with my patch, then make it yours. If we don't need to change anything in the translation component, it's better. |
antograssiot commentedJul 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas I now understood your first comment. Yes I'm missing a test case. A test proving that only one file is generated is missing. I tried to wrote one but I failed and I couldn't find any existing test that could guide me. The only solution that I can see without updating the translation component would be to find a way to filter |
nicolas-grekas commentedJul 18, 2016
@antograssiot see updated patch atmaster...nicolas-grekas:console-translation-domain-choice |
antograssiot commentedJul 18, 2016
@nicolas-grekas It works fine in my case but I'm concerned about |
nicolas-grekas commentedJul 18, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I didn't spot the method was private, fixed. No need to close this PR, just make my patch yours by doing e.g.: |
antograssiot commentedJul 18, 2016
PR updated. Thank you very much@nicolas-grekas for your help and patience |
nicolas-grekas commentedJul 18, 2016
👍 |
fabpot commentedJul 18, 2016
Thank you@antograssiot. |
…ing translations (antograssiot)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle] Allow to specify a domain when updating translations| Q | A| ------------- | ---| Branch? | "master"| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes/| Fixed tickets || License | MIT| Doc PR | noThe MR add the `--domain` option to the `translation:update` console commandWhen working with large number of domains, this helps to reduce the noise in the diff when updating only a translation file.Commits-------a8f3a93 [FrameworkBundle] Allow to specify a domain when updating translations
… a merge (jakzal)This PR was merged into the 3.2-dev branch.Discussion----------[FrameworkBundle] Fix TranslationUpdateCommand tests after a merge| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#19921| License | MIT| Doc PR | -#19325 relied on a wrong count of messages, which was fixed by#19878.Additionally, the `getContainer()` method on the master branch expect messages to be indexed by domain.Commits-------d093c40 [FrameworkBundle] Fix TranslationUpdateCommand tests after a merge
Uh oh!
There was an error while loading.Please reload this page.
The MR add the
--domainoption to thetranslation:updateconsole commandWhen working with large number of domains, this helps to reduce the noise in the diff when updating only a translation file.