Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[FrameworkBundle][Translation] addLocaleSwitcher
service#45793
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
LocaleSwitcher
serviceLocaleSwitcher
service8b9e60e
toacf8082
CompareThere 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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
d09e0d3
to83379b8
CompareTests added, fabbot failure is unrelated to this PR. |
Thank you@kbond. |
I'm proposing#46045 on top of this PR. |
…ekas)This PR was merged into the 6.1 branch.Discussion----------[Translation] Improve LocaleSwitcher a bit| Q | A| ------------- | ---| Branch? | 6.1| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | -| License | MIT| Doc PR | -Today's blog post made me review#45793. Here are changes I think would be nice doing.This is an edgy feature btw to me because it builds on mutable services. An idea that I did not submit here would be to rename LocaleSwitcher to LocaleProvider and tell ppl that need the locale to use this instead of storing the locale as a string in a property. Dunno if that'd make sense to others.Commits-------a71f328 [Translation] Improve LocaleSwitcher a bit
…leSwitcher in a class_exists call (larowlan)This PR was merged into the 6.2 branch.Discussion----------[Translation] Wrap call to \Locale::setDefault from LocaleSwitcher in a class_exists call| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets | N/a - see below| License | MIT| Doc PR | n/aIn#45793 a new LocaleSwitcher was added which uses the \Locale class from ext-intl.On upgrading an English only project from 5.4 to 6.2, I received the following error as we don't have the ext-intl extension```Error: Class "Locale" not found```I searched for previous PRs to add a dependency on `ext-intl` and [came across one](#49280) for the string component directing the user to install a polyfill.Should symfony/translation therefore depend on the polyfill - otherwise updating is broken without manually installing the polyfill?If so, here's a PR for that.Keep up the good work folks ❤️Commits-------c043e93 Wrap use of \Locale in a class_exists test
Uh oh!
There was an error while loading.Please reload this page.
This adds a
LocaleSwitcher
object/service. When setting it's locale, it sets it for allkernel.locale_aware
services,\Locale
, and, if applicable, the_locale
parameter for theRequestContext
. AswitchLocale()
convenience method exists to do set the locale, execute a callback, and set the locale back to the original.Usage:
Todo: