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

[TwigBridge][TwigBundle] Add current locale toAppVariable#49913

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

Merged
fabpot merged 1 commit intosymfony:6.3fromSVillette:twig-bridge-app-locale
Apr 11, 2023
Merged

[TwigBridge][TwigBundle] Add current locale toAppVariable#49913

fabpot merged 1 commit intosymfony:6.3fromSVillette:twig-bridge-app-locale
Apr 11, 2023

Conversation

@SVillette
Copy link
Contributor

@SVilletteSVillette commentedApr 3, 2023
edited
Loading

QA
Branch?6.3
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#49870
LicenseMIT
Doc PRsymfony/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 withinLocaleSwitcher::runWithLocale().

#[AsController]finalclass HomeController{    #[Route('/', name:'app_home')]publicfunction__invoke(LocaleSwitcher$localeSwitcher,Environment$twig):Response    {$localeSwitcher->setLocale('en');return$localeSwitcher->runWithLocale('fr',function ()use ($twig) {returnnewResponse($twig->render('index.html.twig'));        });    }}
{{app.locale }} // fr

A doc PR will be submitted if this change is accepted.

aprat84 reacted with hooray emojidmaicher, smnandre, and andreybolonin reacted with rocket emoji
@carsonbotcarsonbot added this to the6.3 milestoneApr 3, 2023
@carsonbotcarsonbot changed the title[TwigBridge] [TwigBundle] Add current locale toAppVariable[TwigBridge][TwigBundle] Add current locale toAppVariableApr 3, 2023
@SVillette
Copy link
ContributorAuthor

About the failing tests, I may need some help / directions here.

  • TheIntegration / Integration (8.1) seems to be unrelated to this PR (Cache related).
  • TheUnit Tests / Unit Tests (8.1) is failing becauseAppVariable::setLocaleSwitcher() does not have a return type and is not listed in.github/expected-missing-return-types.diff. Updating this file should resolve the issue but I can't do it as they are bunch of other changes here.
  • TheUnit Tests / Unit Tests (8.1, low-deps) fails becauseLocaleSwitcher class is missing. Do I have to skip the test if the class does not exist ?
  • Finally,continuous-integration/appveyor/pr fail seems unrelated to this PR (VarDumper issue).

@stof
Copy link
Member

stof commentedApr 7, 2023

For low-deps, you need to increase the lower bound of the requirement

@SVillette
Copy link
ContributorAuthor

Thank you for the input, CI is still failling but not because of this PR.

@fabpot
Copy link
Member

Thank you@SVillette.

@fabpotfabpot merged commit6b92f5d intosymfony:6.3Apr 11, 2023
@SVilletteSVillette deleted the twig-bridge-app-locale branchApril 11, 2023 18:16
OskarStark added a commit to symfony/symfony-docs that referenced this pull requestApr 14, 2023
This PR was merged into the 6.3 branch.Discussion----------Add Twig `app.locale` documentationThe PR add documentation ofsymfony/symfony#49913Commits-------ac51842 docs: add `app.locale` from Twig `AppVariable`
@curry684
Copy link
Contributor

When installing the Twig Bundle 6.3.0-BETA1 this breaks the application if you didn't directly add the bridge as well:

!!    [Symfony\Component\ErrorHandler\Error\UndefinedMethodError]!!    Attempted to call an undefined method named"setLocaleSwitcher" of class"S!!    ymfony\Bridge\Twig\AppVariable".

Bundle 6.3 is thus incompatible with Bridge 6.2 yet this is not enforced through dependencies.

fabpot added a commit that referenced this pull requestMay 7, 2023
…version (SVillette)This PR was merged into the 6.3 branch.Discussion----------[TwigBundle] fixed wrong `symfony/twig-bridge` dependency version| Q             | A| ------------- | ---| Branch?       | 6.3| Bug fix?      | yes| New feature?  | no| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       |Fix#50245| License       | MIT| Doc PR        | -`TwigBundle` had wrong dependency version  after#49913. This PR fixes this issue.Commits-------c05f484 fix(twig-bundle): fixed wrong `symfony/twig-bridge` dependency
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@stofstofstof approved these changes

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

[TwigBridge] Add current locale toAppVariable service

5 participants

@SVillette@stof@fabpot@curry684@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp