Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Translation] Fix default value for locales in translation push|pull commands#41504

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

Conversation

@welcoMattic
Copy link
Member

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#41501
LicenseMIT
Doc PR

This PR ensures that$locales are always defined eitherframework.translator.enabled_locales orframework.translator.providers.(loco|lokalise|crowdin).locales is defined. Until now, the code expectedframework.translator.enabled_locales to be defined, now if it's not, we merge allframework.translator.providers.(loco|lokalise|crowdin).locales values and pass them toconsole.command.translation_pull andconsole.command.translation_push definitions.

thrownewLogicException(sprintf('You must specify one of "framework.translator.enabled_locales" or "framework.translator.providers.%s.locales" in order to use translation providers.',$name));
}

$locales =array_merge($locales,$provider['locales']);

Choose a reason for hiding this comment

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

Is array_merge really the intended way here? Shouldn't the locale options for the provider be what controls what locales get sent to the provider, even if we have more locales enabled?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Actually we want to pass to the commands all locales supported by all configured providers, in order to read local translations. That's why thelocales property of theTranslationPushCommand hasenabledLocales as default value (https://github.com/symfony/symfony/pull/41504/files#diff-a00f86baf85c337ee61148e5fff8d189edf224ef40382518307359f579f40e6aR66).

Then, theFilteringProvider class is a decorator for each actual provider, and in itsread method, we intersect domains and locales : the ones come from the provider configurations, the others come from theread call from the command class.

But I'm ok, we need to review this part, to make it more explicit and more logical. One of the solution might be to use only locales of providers configuration, make this parameter mandatory? WDYT@nicolas-grekas, in terms of design?

Choose a reason for hiding this comment

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

I've no strong opinion. I'm fine with the current design.
But if someone disagrees, I'd be happy to know why.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Are@OskarStark or@Nyholm has an opinion on it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@nicolas-grekasnicolas-grekas changed the base branch from5.4 to5.3June 2, 2021 09:38
@nicolas-grekasnicolas-grekas added this to the5.3 milestoneJun 2, 2021
@welcoMattic
Copy link
MemberAuthor

I just figured out there no relevant reason thatenabled_locales was related to the locales passed to the push and pull commands. In fact, someone could need to pull/push translation for a locales which is not (yet) enabled.

WDTY about not set locales for Providers fromenabled_locales?

@nicolas-grekas
Copy link
Member

It's true that this line might be strange:
https://github.com/welcoMattic/symfony/blob/94a451dcd1dd44a20a1b8038d1a12b80255460f6/src/Symfony/Component/Translation/Command/TranslationPushCommand.php#L100

I don't see how the 2nd DI parameter that ismentionned in the message relates to the command.
Maybe the command should default to the list of locales of each provider? Is that doable?

@welcoMattic
Copy link
MemberAuthor

welcoMattic commentedJun 14, 2021
edited
Loading

It's pretty much what I thought to do, and make the following behaviour:

A provider will treat all locales (framework.translator.enabled_locales) by default, unless we pass explicit locales via CLI options.

Are we agree on it?

@welcoMatticwelcoMatticforce-pushed thefix/translation-providers-locales-config branch from94a451d to375b058CompareJuly 25, 2021 09:40
@welcoMattic
Copy link
MemberAuthor

I've just pushed an update to useenabled_locales by default, and append allframework.translator.providers.(loco|lokalise|crowdin).locales values, thenarray_unique the result. It will allow users to defined a common list of locales for push/pull commands, and specify additional locales (for instance, a not yet enabled locale) for one or more provider.

@fabpot
Copy link
Member

Thank you@welcoMattic.

@fabpotfabpot merged commit88c5349 intosymfony:5.3Jul 25, 2021
@fabpotfabpot mentioned this pull requestJul 26, 2021
@welcoMatticwelcoMattic deleted the fix/translation-providers-locales-config branchNovember 10, 2021 08:34
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@fabpotfabpotfabpot approved these changes

+1 more reviewer

@DevScyuDevScyuDevScyu left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

[Translation] Push command error

5 participants

@welcoMattic@nicolas-grekas@fabpot@DevScyu@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp