-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #49913 [TwigBridge][TwigBundle] Add current locale to `AppVar…
…iable` (SVillette) This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [TwigBridge][TwigBundle] Add current locale to `AppVariable` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #49870 | License | MIT | Doc PR | symfony/symfony-docs#18190 As stated in #49870, they were no way to get the current locale without passing it through a variable when rendering a template within `LocaleSwitcher::runWithLocale()`. ```php #[AsController] final class HomeController { #[Route('/', name: 'app_home')] public function __invoke(LocaleSwitcher $localeSwitcher, Environment $twig): Response { $localeSwitcher->setLocale('en'); return $localeSwitcher->runWithLocale('fr', function () use ($twig) { return new Response($twig->render('index.html.twig')); }); } } ``` ```twig {{ app.locale }} // fr ``` A doc PR will be submitted if this change is accepted. Commits ------- 2371216 [TwigBridge][TwigBundle] Add current locale to `AppVariable`
- Loading branch information
Showing
5 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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