-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Allow usage of Provider domains if possible #45171
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
[Translation] Allow usage of Provider domains if possible #45171
Conversation
Hey! I think @rvanlaak has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
src/Symfony/Component/Translation/Command/TranslationPushCommand.php
Outdated
Show resolved
Hide resolved
@welcoMattic Do you have time to answer Nicolas's question? Is it ready to be merged then? |
Thank you for MR! I suggest to merge it to 5.4 but not to 6.1 because actually this can be considered as a fix for more obvious behavior. I've also been surprised when discovered the domains are got not from config. |
6e02668
to
2533821
Compare
@fabpot I fixed @nicolas-grekas comment, it's ready to merge now, sorry for the delay @ossinkine we must consider it as a feature, because nothing is properly broken here |
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 looks like a bugfix to me as there is no way to opt-out of the proposed behavior. If it's a feature, it's a behavioral BC break then, which would be no-go ;)
2533821
to
274625f
Compare
According to discussion with @nicolas-grekas, this PR is a bugfix. It's rebased on 5.4 |
274625f
to
b752653
Compare
Thank you @welcoMattic. |
It seems the problem still persist. $domains is set from the $provider->getDomains() after reading local translations for all domains (if we don't pass 'domains' command option). Maybe we can handle this issue with something like this ? $domains = $domainsInput = $input->getOption('domains');
if ($provider instanceof FilteringProvider) {
$providerDomains = $provider->getDomains();
if ($providerDomains) {
$domains = $domains ? array_intersect($domains, $providerDomains) : $providerDomains;
if (!$domains) {
$io->error(sprintf('The provider is configured for this domains: "%s", "%s" provided', implode(', ', $providerDomains), implode(', ',$domainsInput) ));
return Command::FAILURE;
}
}
}
$localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths);
if (!$domains) {
$domains = $this->getDomainsFromTranslatorBag($localTranslations);
} |
Or maybe we should handle the case in FilteringProvider::write (and FilteringProvider::delete ?), it seems more logical to filter domains here |
… the provider has domains (Florian-B) This PR was merged into the 5.4 branch. Discussion ---------- [Translation] Refresh local translations on PushCommand if the provider has domains | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | no | License | MIT | Doc PR | no Since #45171 it's possible to define targeted translation domains in configuration. On `translation:push` without `--domains` option the command should read our configuration in order build local translations list. If the domain is only define in the configuration we need to refresh the local translations list to prevent full update of Provider (push all domains without filtering). I think we should add a test but I failed to do it properly. Commits ------- 8b0f7eb [Translation] Refresh local translations if the provider has domains
This PR adds possibility for
translation:push
command to use the configured domains value for a provider, if there is no--domains
option provided.Before that, the command tries to get the domains from the
MessageCatalog
of all local translations (includingvalidators
andsecurity
even if the user doesn't override these files).Now, we can configure
domains
intranslation.yaml
:And
bin/console translation:push lokalise
will take['messages']
as domains value, instead of['messages', 'validators', 'security']
.