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

[Form] Support Translatable Enum#18599

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
OskarStark merged 1 commit intosymfony:6.4fromSeb33300:patch-3
Jul 27, 2023
Merged

Conversation

@Seb33300
Copy link
Contributor

Documentation forsymfony/symfony#50931

@Seb33300Seb33300 requested a review fromxabbuh as acode ownerJuly 23, 2023 16:21
@Seb33300Seb33300 changed the base branch from6.3 to6.4July 23, 2023 16:23
@javiereguiluzjaviereguiluz added the Waiting Code MergeDocs for features pending to be merged labelJul 24, 2023
@carsonbotcarsonbot added this to thenext milestoneJul 24, 2023
derrabus added a commit to symfony/symfony that referenced this pull requestJul 24, 2023
This PR was squashed before being merged into the 6.4 branch.Discussion----------[Form] Support Translatable Enum| Q             | A| ------------- | ---| Branch?       | 6.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fix#50919| License       | MIT| Doc PR        |symfony/symfony-docs#18599This PR introduce support for Enum implementing `TranslatableInterface` in `EnumType`.Example of use:```php$builder->add('textAlign', EnumType::class, [    'class' => TextAlign::class,])``````phpuse Symfony\Contracts\Translation\TranslatableInterface;use Symfony\Contracts\Translation\TranslatorInterface;enum TextAlign: int implements TranslatableInterface{    case Left = 1;    case Center = 2;    case Right = 3;    public function trans(TranslatorInterface $translator, string $locale = null): string    {        // Translate enum from name (Left, Center or Right)        return $translator->trans($this->name, locale: $locale);        // Translate enum from custom labels        return match ($this) {            self::Left   => $translator->trans('Left aligned', locale: $locale),            self::Center => $translator->trans('Centered', locale: $locale),            self::Right  => $translator->trans('Right aligned', locale: $locale),        };    }}```Commits-------65f26da [Form] Support Translatable Enum
symfony-splitter pushed a commit to symfony/form that referenced this pull requestJul 24, 2023
This PR was squashed before being merged into the 6.4 branch.Discussion----------[Form] Support Translatable Enum| Q             | A| ------------- | ---| Branch?       | 6.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fixsymfony/symfony#50919| License       | MIT| Doc PR        |symfony/symfony-docs#18599This PR introduce support for Enum implementing `TranslatableInterface` in `EnumType`.Example of use:```php$builder->add('textAlign', EnumType::class, [    'class' => TextAlign::class,])``````phpuse Symfony\Contracts\Translation\TranslatableInterface;use Symfony\Contracts\Translation\TranslatorInterface;enum TextAlign: int implements TranslatableInterface{    case Left = 1;    case Center = 2;    case Right = 3;    public function trans(TranslatorInterface $translator, string $locale = null): string    {        // Translate enum from name (Left, Center or Right)        return $translator->trans($this->name, locale: $locale);        // Translate enum from custom labels        return match ($this) {            self::Left   => $translator->trans('Left aligned', locale: $locale),            self::Center => $translator->trans('Centered', locale: $locale),            self::Right  => $translator->trans('Right aligned', locale: $locale),        };    }}```Commits-------65f26dad9c [Form] Support Translatable Enum
@derrabus
Copy link
Member

Code PR has been merged.

@xabbuhxabbuh modified the milestones:next,6.4Jul 25, 2023
@xabbuhxabbuh removed the Waiting Code MergeDocs for features pending to be merged labelJul 25, 2023
@xabbuh
Copy link
Member

We also need aversionadded directive which explains that you can use this feature since Symfony 6.4.

derrabus reacted with thumbs up emoji

@Seb33300
Copy link
ContributorAuthor

Added

@OskarStark
Copy link
Contributor

Thanks for your work on this new feature!

Seb33300 reacted with heart emoji

@OskarStarkOskarStark merged commit8612bab intosymfony:6.4Jul 27, 2023
@Seb33300Seb33300 deleted the patch-3 branchJuly 27, 2023 13:09
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

+1 more reviewer

@derrabusderrabusderrabus requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

6 participants

@Seb33300@derrabus@xabbuh@OskarStark@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp