Repository navigation
Enhancing Laravel: Introducing Enum Translation for a Seamless Developer Experience #49464
Unanswered
domthomas-dev
asked this question in
Ideas
Replies: 5 comments 1 reply
|
Something like this |
0 replies
|
I don't have any answers, so I created a package, but it would be better directly in the chore. Of course, I can take care of it, with the documentation etc. |
0 replies
|
this is already easy enough to do in userland: enum Test: string
{
case FOO = 'foo';
case BAR = 'bar';
case BAZ = 'baz';
public function display(): string
{
return match ($this) {
self::FOO => __('enums/foo'),
self::BAR => __('enums/bar'),
self::BAZ => __('enums/baz'),
};
} |
1 reply
|
I don't believe, enum values should be used for this (directly). There's also |
0 replies
|
I have created a package that manages Enum translation in an elegant way |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hey Laravel Core Team,
I've got a suggestion that could level up the developer experience with the framework: how about adding a feature to translate enums? Ever thought about it?
Enums are super handy, but things get a bit tricky when we're dealing with different languages. Having a function to translate enums directly would be a game-changer!
Just imagine being able to set translations for each enum value in language files. It would make managing multilingual apps a breeze without making the code overly complicated.
It would be awesome if you could consider this idea for upcoming Laravel versions. It would make developers' lives so much easier and amp up the framework's adaptability.
I'm totally up for a more detailed discussion if you're interested! Thanks for everything you do to evolve Laravel.
I can work on it if you think it's a good idea.
Thanks
Dom
All reactions