-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Translation] add LocaleSwitcher
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LocaleSwitcher
serviceLocaleSwitcher
service
8b9e60e
to
acf8082
Compare
ro0NL
reviewed
Mar 19, 2022
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.
ro0NL
reviewed
Mar 20, 2022
kbond
commented
Mar 20, 2022
kbond
commented
Mar 20, 2022
d09e0d3
to
83379b8
Compare
Tests added, fabbot failure is unrelated to this PR. |
fabpot
approved these changes
Mar 26, 2022
Thank you @kbond. |
I'm proposing #46045 on top of this PR. |
fabpot
added a commit
that referenced
this pull request
Apr 14, 2022
…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
Merged
nicolas-grekas
added a commit
that referenced
this pull request
Mar 7, 2023
…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/a In #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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: