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

[Translation] Give current locale toLocaleSwitcher::runWithLocale()'s callback#51684

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

Conversation

@alexander-schranz
Copy link
Contributor

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

I think it would not hurt to give the $locale everytime to the callback method.

Example usage:

$notificationContent =$this->localeSwitcher->runWithLocale($contact->getLocale(),function(string$locale)use ($someEntity):string {$title =$someEntity->getTitle($locale);return$this->twig->render('template.html.twig', ['title' =>$title]);});

Alternative solution currently is:

$locale =$contact->getLocale();$notificationContent =$this->localeSwitcher->runWithLocale($locale,function()use ($locale,$someEntity):string {$title =$someEntity->getTitle($locale);return$this->twig->render('template.html.twig', ['title' =>$title]);});

So this avoids creating a$locale variable which maybe only is necessary inside the callback method.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add a line in the changelog :)

welcoMattic reacted with thumbs up emoji
@welcoMatticwelcoMattic changed the titleGive current locale to locale switcher runWithLocale callback[Translation] Give current locale to locale switcher runWithLocale callbackSep 20, 2023
@nicolas-grekasnicolas-grekas changed the title[Translation] Give current locale to locale switcher runWithLocale callback[Translation] Give current locale toLocaleSwitcher::runWithLocale()'s callbackSep 20, 2023
@nicolas-grekasnicolas-grekasforce-pushed thefeature/local-switcher-locale branch from9b9f64f to4c658ceCompareSeptember 20, 2023 09:18
@nicolas-grekas
Copy link
Member

Thank you@alexander-schranz.

@nicolas-grekasnicolas-grekas merged commitc49e2d7 intosymfony:6.4Sep 20, 2023
@alexander-schranzalexander-schranz deleted the feature/local-switcher-locale branchSeptember 20, 2023 15:52
@nicolas-grekasnicolas-grekas added this to the6.4 milestoneSep 25, 2023
This was referencedOct 21, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof approved these changes

@welcoMatticwelcoMatticwelcoMattic approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

4 participants

@alexander-schranz@nicolas-grekas@stof@welcoMattic

[8]ページ先頭

©2009-2025 Movatter.jp