-
Notifications
You must be signed in to change notification settings - Fork 20
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add rfc for move i18n logic to frontend #1436
base: main
Are you sure you want to change the base?
Conversation
dt, err := statusEmailIsEmpty.WithDetails( | ||
&errdetails.ErrorInfo{ | ||
Reason: "INVALID", | ||
Domain: "account.bucketeer.io", | ||
Metadata: map[string]string{ | ||
"messageKey": "account.invalid.empty", | ||
"feild": "email", | ||
}, | ||
}) | ||
if err != nil { | ||
return statusInternal.Err() | ||
} | ||
return dt.Err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to put this log logic into a common function.
Depending on the function, we handle many errors, making the function too long.
One of the reasons for moving the localizer to the front end is also to improve code readability.
WDYT?
dt, err := statusEmailIsEmpty.WithDetails( | |
&errdetails.ErrorInfo{ | |
Reason: "INVALID", | |
Domain: "account.bucketeer.io", | |
Metadata: map[string]string{ | |
"messageKey": "account.invalid.empty", | |
"feild": "email", | |
}, | |
}) | |
if err != nil { | |
return statusInternal.Err() | |
} | |
return dt.Err() | |
return error.NewError(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Good idea!
It's certainly more readable that way, so I do that when coding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kakcy, can you update the RFC using the code above? Leave it as it is a bit confusing.
I'm more interested in how the code will look in the end. How readable the code will be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cre8ivejp
I Added information regarding NewError()
to the rfc.
please check.
``` | ||
|
||
## Release Steps | ||
1. Releases a process that returns an ErrorInfo for each package for The backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, we will use canary release to switch i18n logic from backend to fronted, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right. Bucketeer essentially uses a canary release.
@Ubisoft-potato, @hvn2k1, can you check the latest changes? |
@cre8ivejp Looks great! 🎉 |
... | ||
``` | ||
|
||
### Point3:Remove localize massage code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kakcy, I see the relation between point 1 and point 2, it looks great, but I don't understand point 3, what is it relation to point 1 and 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, error messages are localized on the backend using errdetails.LocalizedMessage as shown below.
bucketeer/pkg/account/api/validation.go
Lines 624 to 627 in ddbd7f0
dt, err := statusEmailIsEmpty.WithDetails(&errdetails.LocalizedMessage{ | |
Locale: localizer.GetLocale(), | |
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "email"), | |
}) |
Modify Point1 and Point2 to use errdetails.ErrorInfo
to send error details to the front end.
The content described in Point 3 is
Once the localization of error messages using errdetails.ErrorInfo
is completed on the front end, errdetails.LocalizedMessage
will no longer be necessary, so it should be deleted.
What do you think?
This pull request proposes moving the i18n (internationalization) logic entirely to the frontend to simplify the backend code. The changes include adding detailed documentation and examples of the new error handling design using GRPC's
ErrorInfo
and removing the existingLocalizedMessage
code from the backend.#1253