Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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
[Translation] Fix default value for locales in translation push|pull commands#41504
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| 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']); |
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.
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?
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.
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?
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've no strong opinion. I'm fine with the current design.
But if someone disagrees, I'd be happy to know why.
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.
Are@OskarStark or@Nyholm has an opinion 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.
Uh oh!
There was an error while loading.Please reload this page.
welcoMattic commentedJun 5, 2021
I just figured out there no relevant reason that WDTY about not set locales for Providers from |
nicolas-grekas commentedJun 8, 2021
It's true that this line might be strange: I don't see how the 2nd DI parameter that ismentionned in the message relates to the command. |
welcoMattic commentedJun 14, 2021 • 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.
It's pretty much what I thought to do, and make the following behaviour: A provider will treat all locales ( Are we agree on it? |
94a451d to375b058ComparewelcoMattic commentedJul 25, 2021
I've just pushed an update to use |
fabpot commentedJul 25, 2021
Thank you@welcoMattic. |
This PR ensures that
$localesare always defined eitherframework.translator.enabled_localesorframework.translator.providers.(loco|lokalise|crowdin).localesis defined. Until now, the code expectedframework.translator.enabled_localesto be defined, now if it's not, we merge allframework.translator.providers.(loco|lokalise|crowdin).localesvalues and pass them toconsole.command.translation_pullandconsole.command.translation_pushdefinitions.