-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Add completion to debug:translation command #43644
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
[FrameworkBundle] Add completion to debug:translation command #43644
Conversation
alexandre-daubois
commented
Oct 22, 2021
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 5.4 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Tickets | Part of #43594 |
License | MIT |
Doc PR | NA |
2d1f985
to
b0a55a4
Compare
Completion don't have to be exhaustive. Bundle names can be completed getting the name of each bundle provided by |
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void | ||
{ | ||
if ($input->mustSuggestArgumentValuesFor('locale')) { | ||
$suggestions->suggestValues(Locales::getLocales()); |
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.
This is a very long list. Since this command describes the state of the application, I think it would be more useful if only the used locales were listed.
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.
No problem, taking a look at 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'm working on another translation related command that require to autocomplete for locale too.
I'm thinking if we're going to have only used locales, maybe we will need to add getUsedLocals()
into ExtractorInterface
and TranslationReaderInterface
So far I only know the we need to do as below if we're adding into the interface.
TranslationReader
need to put the logic for getting the Locales
ChainExtractor
and PhpExtractor
also need to add the logic to get used Locales.
Quick global search within the repo also gave me one more class that needs update:
Symfony\Bridge\Twig\Translation\TwigExtractor
But not quite sure if it will affect other third party package.
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.
Also might need to consider third party translation loader included as the autocomplete suggestions.
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.
FrameworkBundle has a concept of enabled locales. I suggest using those for the completion.
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.
Does this really make sense to limit locales completion to the "enabled" ones in the project, aside that it seems tricky to get these enabled locales? Symfony already bundles a lot of messages in dozens of locales. Restricting completion could kind of prevent displaying messages defined by Symfony in domains like the validators
one.
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.
Here, it's only about completion, I'm fine with auto-completing only the enabled locales. If you want another one, just type it explicitly.
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.
Alright, I'm on 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.
@stephenkhoo to access the enabled locales, use DI, i.e. inject them in the command constructor.
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.
Got it, thanks
b0a55a4
to
a1c32b4
Compare
Suits me fine. Added! |
a1c32b4
to
1388391
Compare
1529f97
to
454d1b5
Compare
454d1b5
to
621d83c
Compare
621d83c
to
086a8b4
Compare
…n:update command (stephenkhoo) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Add completion feature on translation:update command | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Part of #43594 | License | MIT | Doc PR | - Adding completion for translation:update. - [x] locale - [X] bundle - [X] --format - [X] --domain - [X] --sort Test for - [x] locale - [x] bundle - [X] --format - [X] --domain - [X] --sort Locale completion still under discussion in #43644 (review) Locale and bundle test still not complete Commits ------- 2f301ae [FrameworkBundle] Add completion feature on translation:update command
…n:update command (stephenkhoo) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Add completion feature on translation:update command | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Part of #43594 | License | MIT | Doc PR | - Adding completion for translation:update. - [x] locale - [X] bundle - [X] --format - [X] --domain - [X] --sort Test for - [x] locale - [x] bundle - [X] --format - [X] --domain - [X] --sort Locale completion still under discussion in symfony/symfony#43644 (review) Locale and bundle test still not complete Commits ------- 2f301ae9e1 [FrameworkBundle] Add completion feature on translation:update command
Thank you @alexandre-daubois. |
|
||
yield 'bundle' => [ | ||
['fr', '--domain', 'messages', ''], | ||
['ExtensionWithoutConfigTestBundle', 'extension_without_config_test'], |
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 get an exception when I use the bundle_name in snake case. Does it work for you? (It's ok with BundleName)
$ bin/console debug:translation en framework
"framework/translations" is neither an enabled bundle nor a directory.
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.
Taking a look ASAP 👍