Skip to content

[Translation] Refresh local translations on PushCommand if the provider has domains #46239

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

Merged
merged 1 commit into from
May 6, 2022

Conversation

Florian-B
Copy link
Contributor

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.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@@ -136,6 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (!$domains) {
if ($provider instanceof FilteringProvider) {
$domains = $provider->getDomains();
$localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths);
Copy link
Member

@welcoMattic welcoMattic May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's better to not refresh translations, but read them after the main if (!$domains) { block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was my first idea, but the variable $localTranslations is used in the if (!$domains) { block at line 143

$domains = $this->getDomainsFromTranslatorBag($localTranslations);

We can also rewrite the if (!$domains) { block a bit like this :

if (!$domains && $provider instanceof FilteringProvider) {
	$domains = $provider->getDomains();
}

$localTranslations = $this->readLocalTranslations($locales, $domains, $this->transPaths);

if (!$domains) {
	$domains = $this->getDomainsFromTranslatorBag($localTranslations);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@chalasr
Copy link
Member

chalasr commented May 6, 2022

If there is no relevant way to add a test for this, can we at least put a phpdoc comment to ease catching regressions?

@Florian-B Florian-B force-pushed the fix/translator-provider-domains branch from d4d0bb2 to 8b0f7eb Compare May 6, 2022 12:34
@Florian-B
Copy link
Contributor Author

If there is no relevant way to add a test for this, can we at least put a phpdoc comment to ease catching regressions?

Done 👍

@chalasr
Copy link
Member

chalasr commented May 6, 2022

Good catch, thanks @Florian-B.

@chalasr chalasr merged commit 37b8077 into symfony:5.4 May 6, 2022
@fabpot fabpot mentioned this pull request May 14, 2022
This was referenced May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants