mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 00:55:12 +00:00
feat: translate error messages (#254)
* feat: translate error messages in error interceptor * fix: add statik import * feat: user error msgs * feat: add translations * feat: add translations * feat: add translations * feat: add translations * feat: add translations * feat: add translations * some fixes and improved error messages Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/i18n"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
func CaosToGRPCError(err error) error {
|
||||
func CaosToGRPCError(err error, ctx context.Context, translator *i18n.Translator) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -15,6 +16,10 @@ func CaosToGRPCError(err error) error {
|
||||
if !ok {
|
||||
return status.Convert(err).Err()
|
||||
}
|
||||
if translator != nil {
|
||||
msg = translator.LocalizeFromCtx(ctx, msg, nil)
|
||||
|
||||
}
|
||||
return status.Error(code, msg)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user